Program to find largest, smallest, sum and average


#include<stdio.h>
main()
{
      int x[5];
      int i, large, small, sum=0;
      float ave;
//taking values for array
      for(i=0;i<5;i++)
         {
         printf("Enter the value for %d variable :",i+1);
         scanf("%d",&x[i]);
         }
//print largest and smallest
      large=small=x[0];
      for(i=0;i<5;i++)
         {
         if(x[i]>large)
         large=x[i];
         if(x[i]<small)
         small=x[i];
         }
      printf("\nLarge Number is %d",large);
      printf("\nSmallest Number is %d",small);
//find sum and average
      for(i=0;i<5;i++)
         sum+=x[i];
         ave=sum/5.0;
         printf("\n\nThe sum is %d",sum);
         printf("\nThe average is %.2f",ave);
      getch();
}

Comments

Popular posts from this blog

Customize User's Profile in ASP.NET Identity System

Migrating database from ASP.NET Identity to ASP.NET Core Identity