Write a program in C++, to print the sum of first 100 natural numbers using for control structure.
Write a program in C++, to print the sum of first 100 natural numbers using for control structure.
Write a program in C++, to print the sum of first 100 natural numbers using for control structure.
Best answer
#include <iostream>
using namespace std;
int main()
{
int i, sum=0;
for(i=1;i<=100;i++)
{
sum=sum+i;
}
cout<<"Sum of first 100 natural numbers is: "<<sum;
return 0;
}
Output::
Log in or create a free account to answer this question.