Tuesday, 3 July 2018

how to calculate the sum of all the numbers number is taken from the user

 Write a program that calculate the sum of all the number that is entered by user


///////// solutions 

   

#include <iostream>
using namespace std;

int main() {

 int sum,n;
 cout<<"Enter the number plase "<<endl;
 cin>>n;
sum=(n*(n+1))/2;
cout<<"The sum is "<<sum<<endl;

}

No comments:

Post a Comment