Program to input 5 values in an array and find their sum

#include<stdio.h>
#include<conio.h>
void main()
{
 int x[5],i,sum=0;
 clrscr();
  for(i=0;i<5;i++)
  {
   printf("\nEnter No ");
   scanf("%d",&x[i]);
  }
  for (i=0;i<5;i++)
  {
   printf("\n\tx[%d]==%d",i,x[i]);
   sum=sum+x[i];
  }
  printf("\n\nSum is %d",sum);
  getch();
}

Leave a Reply