0
How to create a program using for loop that takes 15 numbers from 10 to 30 and calculates their sum
2 ответов
+ 2
From where it take data, user?
+ 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;
}



