24. Program to print the following sequence: 8 12 17 24 28 33 ... 100

Chapter 6: 

Looping Structures

Programming Exercise

Problem # 24:

Write a program to print the following sequence:
8 12 17 24 28 33 ... 100

Solution:

#include<iostream>
#include<conio.h>
using namespace std;
int main()
{
    int c=8;
    do
    {
        cout<<c<<"\t";
        c=c+4;
        if(c==100)
        break;
        else
        cout<<c<<"\t";
        c=c+5;
        if(c==100)
        break;
        else
        cout<<c<<"\t";
        c=c+7;   
    }
    while(c<=100);
    getch();   
}

Let me know in the comment section if you have any question.

Previous Post:
23. Program to print the following sequence: 1 3 9 27 81 ... 200

Comments