Write a program in C to enter any 10 integers in 1 D array and display the total sum of those digits.
Hello , learner welcome you on my blog today in this post we discus a "C language " program that will contain 10 integer value in an array and display the sum of integer values.
Now , to make a program in 'c' to solve the above problem first declare two variable, for storing integer value [integer array] and result [integer], take ten integer value by using for loop , calculate sum and then display the result.
C code for above problem:
#include<stdio.h>.
int main()
{
int array[10], sum = 0;
for(int i = 0; i<10; i++){
printf("Enter %dth integer: " , i+1 );
scanf("%d", &array[i]);
}
for(int j = 0; j < 10; j++){
sum = sum + array[j];
}
printf("sum of entered integer = %d", sum);
return 0;
}
Output :
Run program and enter ten Integer value then you get sum of all integer that you have entered.
Than you
Feel free to comment.
0 comments:
Post a Comment