0 votes
1.4k views
in Programming by (98.9k points)
edited

Write a program in C++, to print the sum of first 100 natural numbers using for control structure.

1 Answer

0 votes
by (98.9k points)
selected by
 
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::
image

Related questions

0 votes
1 answer 435 views
0 votes
1 answer 1.3k views

Doubtly is an online community for engineering students, offering:

  • Free viva questions PDFs
  • Previous year question papers (PYQs)
  • Academic doubt solutions
  • Expert-guided solutions

Get the pro version for free by logging in!

5.7k questions

5.1k answers

108 comments

561 users

...