Tuesday, 3 July 2018

how to calculat the sum of all number from 1 to 100

Write a program that calculate the sum of all the numbers from 1 to 100


///////// solutions 

   

#include <iostream>
using namespace std;

int main() {

 int sum;
sum=(100*101)/2;
cout<<"The sum is "<<sum<<endl;

}

No comments:

Post a Comment