Print the number series 1 3 6 using for loop in C++
for Loop - Question 5
In this question, we will see how to print the number series 1 3 6... in C++ programming using for loop. To know more about for loop click on the for loop lesson.
Q5) Write a program in C++ to print the number series given below using for loop.
1 3 6 10 15 21 28 36 45 55
Program
#include <iostream>
#include <conio.h>
using namespace std;
int main()
{
int i,s=0;
for(i=1; i<=10; i=i+1)
{
s=s+i;
cout<<s<<" ";
}
return 0;
}
Output
1 3 6 10 15 21 28 36 45 55