Write a program to read 10 numbers and find the sum of these numbers?
Source Code
#include <iostream>
using namespace std;
int main()
{
int i,n[10], sum=0;
cout<<" Enter 10 numbers: ";
for(i=0;i<10;i++)
{
cin>>n[i];
sum=sum+n[i];
}
cout<<" Sum of the numbers in array " << sum;
return 0;
}
Output
Enter 10 numbers:
1
2
3
4
5
6
7
8
9
10
Sum of the numbers in array 55
#include <iostream>
using namespace std;
int main()
{
int i,n[10], sum=0;
cout<<" Enter 10 numbers: ";
for(i=0;i<10;i++)
{
cin>>n[i];
sum=sum+n[i];
}
cout<<" Sum of the numbers in array " << sum;
return 0;
}
Output
Enter 10 numbers:
1
2
3
4
5
6
7
8
9
10
Sum of the numbers in array 55
Comments
Post a Comment