Sunday, September 2, 2012

Find Maximum Number in array in C program

Find Maximum Number in array in C program


This program to find the maximum number in 1 Dimensional array. Accept number then compare it with previous maximum if true then replace it with new one as simple as that

/* Program to Find Maximum No in array */
#include<stdio.h>

int main()
{
int a[100],n,i,max=0;
printf("enter the no.:");
scanf("%d",&n);
for(i=1;i<=n;i++)
{
printf("enter the value of %d no.:",i);
scanf("%d",&a[i]);
if(max<a[i])
max=a[i];
}
printf("\nThe max is %d\n",max);
return 0;
}


0 comments:

Post a Comment