Find out the maximum value of an array.

Find out the maximum value of an array.

Program:
#include<stdio.h>
main()
{
int n, i, max, x[50], p, c=0;

printf("Enter number: N= ");
scanf("%d", &n);

for(i=0; i<n; i++)
{
printf("Enter number for [id %d]= ",i);
scanf("%d", &x[i]);
}
max=x[0];
p=0;
for(i=0; i<n; i++)
{
if(x[i]>max)
{
max=x[i];
p=i;
}
if(x[i]==max)
c++;
}
/*
for(i=0; i<n; i++)
{
if(x[i]==max)
c++;
}
*/
printf("Maximum number is=%d \n Position=%d", max,p);
printf("\n Total max=%d", c);
}

Loading
Twitter Delicious Facebook Digg Stumbleupon Favorites More

 
Flying Twitter Bird Widget By ICT Sparkle