ProAnswers.org

Write a C program to find out the Maximum Value in the Array ?

#include

#include 

void main() 

{ 

int a[5],max,i; 

clrscr(); 

printf(“enter elements for the array

”);

for(i=0;i<5;i++) 

scanf(“%d”,&a[i]); 

max=a[0]; 

for(i=1;i<5;i++) 

{ 

if(max

max=a[i]; 

} 

printf(“the maximum value is%d”,max); 

getch(); 

} 

Output: 

enter the elements for array 

4 

6 

3 

8 

5 

 



the maximum value is 8