Add the elements of array and print the addition


#include<stdio.h>
#include<conio.h>
int main()
{
int i,n,a[25],sum=0;
clrscr();
printf("Enter number of elements \n");
scanf("%d",&n);
printf("Enter elements \n");
for(i=0;i<n;i++)
{
scanf("%d",&a[i]);
}
for(i=0;i<n;i++)
{
sum=sum+a[i];
}
printf("\n Sum of matrix elements is %d",sum);
getch();
return 0;
}

0 comments:

Post a Comment