0

How to create a program using for loop that takes 15 numbers from 10 to 30 and calculates their sum

27th Nov 2016, 12:22 PM
Indrit Caca
Indrit Caca - avatar
2 ответов
+ 2
From where it take data, user?
27th Nov 2016, 12:47 PM
Aditya kumar pandey
Aditya kumar pandey - avatar
+ 1
//As per C++:- #include<iostream> using namespace std; int main() { int x[15]; int sum=0; for(int i=0;i<15;i++) { cout<<"\n Enter number " <<(i+1)<<" in the range of 10 to 30 : "<<endl; cin>>x[i]; if(x[i]>=10&&x[i]<=30) sum+=x[i]; else { cout<<"\n Please enter number in the range asked for."<<endl; i-=1; } } cout<<"\n The total of all entered number is : "<<sum<<endl; return 0; }
27th Nov 2016, 12:56 PM
Abhishek Kumar
Abhishek Kumar - avatar