C Program to find sum of elements in array

 C Program to find sum of elements in array





//WAP to print sum of elements of array

#include<stdio.h>
int main()
{
    int i,n,lst[100],sum=0;
    printf("Enter how many elements you want to add:");
    scanf("%d",&i);
  
    for(n=0;n<i;n++) 
    {
        printf("Enter elements:"); 
        scanf("%d",&lst[n]);
     }
    
     for(n=0;n<i;n++)
     {
        sum=sum+lst[n];
       
     }
     printf("\n Sum of elements in array is %d",sum);
    return 0;
}
   

No comments:

Powered by Blogger.