‘C’ program to find the maximum number from an array of n integers.

C File =>


/* Write ‘C’ program to find the maximum number from an array of n 
integers. */

#include<stdio.h>
int main() 
{
       int num[30],i,max=0,n;
       printf("\n How many integers? ");
       scanf("%d",&n);
       printf("\n Enter integers :\n");
 
       for(i=0;i<n;i++)
            scanf("%d",&num[i]);
 
       for(i=0;i<n;i++)
      {
           if(max<num[i])
                  max=num[i];
       }
       printf("\n Maximum of given numbers is : %d",max);

 return 0;
}

Comments

Popular posts from this blog

Write a program to allocate memory dynamically for n integers. Accept the elements and calculate their sum and average

C program to accept names of n cities and search for city named “Pune”.