Friday, 5 July 2013

Print the sum of first 100 natural numbers.

#include<iostream>
using namespace std;
int main()
{
int sum=0;
for(int num=1;num<=100;num++)
{
sum=sum+num;
}
cout<<"The sum of first 100 natural numbers is: "<<sum;
}

No comments:

Post a Comment