Monday, January 21, 2013

write a program to find the sum of the array elements

#include<stdio.h>
  #include<conio.h>
  
  void main()
  {
     int a[5];
     int i,sum=0;
 
     clrscr();
      printf("Enter the array elements\n");
      for (i=0; i<5; i++)
      scanf("%d",&a[i]);
      
      // sum of array elements
      for (i=0; i<5; i++)
      {
        sum=sum+a[i];
      }
      printf("Sum of array elements===%d",sum);
    } // end of main()
 

No comments:

Post a Comment