Below is a C program with an explanation of how to find the largest number in an array.

What is an array?

An array is a group of elements of the same data type. It has a consecutive memory location in memory. Each value in the array is called an element. Every element has the same name as the variable, but different indexes. An array may have any type, like float, int, and char, etc.

Program Source Code

Here is the source code of the C program to find the largest number in an array. This program is successfully compiled, and the output is also given below.

#include <stdio.h>

main ()
  int rang;
  int Array[100];
  printf ("Enter the Size Of Array :");
  scanf ("%d", &rang);

  printf ("Enter Numbers In Array :\n");
  for (int i = 0; i < rang; i++)
      scanf ("%d",&Array[i]);
  int Large_Num = Array[0];
  for (int j = 0; j < rang; j++) 
		if (Large_Num < Array[j])
			Large_Num = Array[j];
   printf("\n Larget Number in Array is : %d", Large_Num);
  return 0;


Program Explanation

Declare an array of any size, also declare another variable of int type to input the size of an array form the user. Use a for-loop to input elements from the user in an array. After reading the values form the user, declare a variable Large_Num, and assign the value of the ‘0’ index of the array to it.

Again, use a for-loop to find the most significant number in the array. Inside for loop, if-statement is used, if the value of Large_Num variable is less than the array specific index, then the value of this particular index is assigned to the Large_Num Variable. This process is repeated until all elements of that array are checked. After that, the largest number will be printed on the screen.

Related C Articles

Last modified: July 10, 2019


Write a Reply or Comment

Your email address will not be published.