Maximum Number In An Array

Introduction
  • This blog helps you to find the maximum or the largest element present in an array. The program is simple and it is easy to understand.
Software Requirement
  • Turbo C++ OR C. 
Programming
  1. #include < stdio.h > int main()   
  2. {  
  3.     int array[100], maximum, size, c, location = 1;  
  4.     printf("Enter the number of elements in array\n");  
  5.     scanf("%d", & size);  
  6.     printf("Enter %d integers\n", size);  
  7.     for (c = 0; c < size; c++) scanf("%d", & array[c]);  
  8.     maximum = array[0];  
  9.     for (c = 1; c < size; c++)  
  10.     {  
  11.         if (array[c] > maximum)  
  12.         {  
  13.             maximum = array[c];  
  14.             location = c + 1;  
  15.         }  
  16.     }  
  17.     printf("Maximum element is present at location %d and it's value is %d.\n", location, maximum);  
  18.     return 0;  
  19. }  
Explanation
  • In the programming, given above, I clearly explained about the maximum element, which is present at the location.

    programming
 
Output

Output
 
Conclusion
  • Thus, the program is printed and executed successfully.
Next Recommended Reading Print Alternate Elements In An Array