Dremendo Tag Line

Print the number series 0 3 8 using while loop in C++

while Loop - Question 6

In this question, we will see how to print the number series 0 3 8 15... up to nth term in C++ programming using while loop. To know more about while loop click on the while loop lesson.

Q6) Write a program in C++ to print the number series given below using while loop.

0 3 8 15... up to nth term

Program

#include <iostream>
#include <conio.h>

using namespace std;

int main()
{
    int i=1,s;

    while(i<=10)
    {
        s=(i*i)-1;
        cout<<s<<" ";
        i=i+1;
    }
    return 0;
}

Output

0 3 8 15 24 35 48 63 80 99
video-poster