Showing posts with label Find Maximum Value in Array. Show all posts
Showing posts with label Find Maximum Value in Array. Show all posts

Tuesday, 17 January 2012

Find Maximum Value in Array


#include<stdio.h>
#include<conio.h>
void main()
{
int a[5],max,i;
clrscr();
printf(“enter elements for the array\n”);
for(i=0;i<5;i++)
scanf(%d”,&a[i]);
max=a[0];
for(i=1;i<5;i++)
{
if(max<a[i])
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