C Program to find sum of the Arrays Elements.

Write a C Program to find sum of the Arrays Elements:

Required Knowledge:

C basics, Arrays

Program:

 1 #include<stdio.h>
 2  void main()
 3  {
 4      int n[5],i;
 5      int sum;
 6  
 7      for(i=0; i<=4; i++)
 8      {
 9          printf("Enter the number  %d:",i+1);
10  
11          scanf("%d",&n[i]);
12      }
13  
14      sum=n[0];
15  
16      for(i=1; i<=4; i++)
17      {
18          sum=sum+n[i];
19      }
20  
21      printf("Sum is:%d",sum);
22  }

Output:


Comments

Popular posts from this blog

C program to calculate velocity

C program to find square root of a number

C program to find maximum between two numbers