adsense

Hii, welcome to my site. My name is Om prakash kartik. This blog helps you to learn programming languages concepts.

Write a program in C to find sum of all array elements.

Write a program in C to find sum of all array elements.

#include<stdio.h>
#include<conio.h>
  void main()
   {
   int a[50],i,sum=0,n;
   clrscr();
   printf("Enter a number you want to inset in array:-");
   scanf("%d",&n);
   printf("Enter %d no.:-",n);
   for(i=0;i<n;i++)
    scanf("%d",&a[i]);
    for(i=0;i<n;i++)
     {
      sum=sum+a[i];
      }
   printf(" Sum =%d",sum);
   getch();
   }

Output:


Post a Comment

0 Comments