Sum of 10 elements using array using C
#include<stdio.h>
#include<conio.h>
void main()
{
int sum=0; //initially sum = 0;
int array[10]; //an array of 10 same data type elements
printf("Enter 10 elements : ");
for(int i=0;i<10;i++)
{
scanf("%d",&array[i]);
sum=sum+array[i]; // sum is updated every time after entering new value in array
}
printf("10 elements you enterd are: ");
for(int i=0;i<10;i++)
{
printf("%d ",array[i]);
}
printf("\nSum of all elements you entered is : %d"sum); // printing sum of all elements
getch();
}
#include<conio.h>
void main()
{
int sum=0; //initially sum = 0;
int array[10]; //an array of 10 same data type elements
printf("Enter 10 elements : ");
for(int i=0;i<10;i++)
{
scanf("%d",&array[i]);
sum=sum+array[i]; // sum is updated every time after entering new value in array
}
printf("10 elements you enterd are: ");
for(int i=0;i<10;i++)
{
printf("%d ",array[i]);
}
printf("\nSum of all elements you entered is : %d"sum); // printing sum of all elements
getch();
}