Program
#include <stdio.h> int main() { printf("**************************************************************"); printf("\n**************************************************************"); printf("\n** WAP to find sum of elements of an array **"); printf("\n** Created by Sheetal Garg **"); printf("\n** Assistant Professor **"); printf("\n** Phone No:9467863365 **"); printf("\n**************************************************************"); printf("\n**************************************************************\n"); int n,i,a[5],sum=0; printf("Enter no. of elements in the array\n"); scanf("%d",&n); printf("enter array elements"); for(i=0;i<n;i++) scanf("%d",&a[i]); for(i=0; i<n; i++) sum=sum + a[i]; printf("sum of elements of array is %d",sum); return 0; }
Output
*************************************************************************** *************************************************************************** ** WAP to find sum of elements of an array ** ** Created by Sheetal Garg ** ** Assistant Professor ** ** Phone No:9467863365 ** *************************************************************************** *************************************************************************** Enter no. of elements in the array 4 enter array elements 34 32 21 25 sum of elements of array is 112