Program : Addition of All Elements of the Array
#include<stdio.h> #include<conio.h> void main() { int i,a[50],sum,n; printf("nEnter no of elements :"); scanf("%d",&n); /* Reading values into Array */ printf("nEnter the values :"); for(i=0;i < n;i++) scanf("%d",&a[i]); /* computation of total */ sum=0; for(i=0;i < n;i++) sum=sum+a[i]; /* printing of all elements of array */ for(i=0;i < n;i++) printf("na[%d]=%d",i,a[i]); /* printing of total */ printf("nSum=%d",sum); }