Q. Write a C program to accept the number of elements to be insert from the user and calculate these elements sum.
For example:
if user enter no. of elements : 5
then he/she should enter elements value as:
Enter 1 element/number : 2
Enter 2 element/number : 7
Enter 3 element/number : 1
Enter 4 element/number : 10
Enter 5 element/number : 50
Result will be :
Sum of elements/numbers : 70
Ans.
/*c program for entered number of elements and calculate the sum*/
#include<stdio.h>
int main()
{
int num,arr[20],i,sum=0;
//arr[20] value of changeable as big value
For example:
if user enter no. of elements : 5
then he/she should enter elements value as:
Enter 1 element/number : 2
Enter 2 element/number : 7
Enter 3 element/number : 1
Enter 4 element/number : 10
Enter 5 element/number : 50
Result will be :
Sum of elements/numbers : 70
Ans.
/*c program for entered number of elements and calculate the sum*/
#include<stdio.h>
int main()
{
int num,arr[20],i,sum=0;
//arr[20] value of changeable as big value