41. Program that uses nested for loops to display the following lines.

Chapter 6: 

Looping Structures

Programming Exercise

Problem # 41:

Write a program that uses nested for loops to display the following lines:
    1    2    4    6
    2    2    4    6
    3    2    4    6
    4    2    4    6

Solution:

#include<iostream>
#include<conio.h>
using namespace std;
int main()
{
    for(int i=1;i<=4;i++)
    {
            cout<<i<<" "<<2<<" "<<4<<" "<<6<<endl;;
    }
}

Output:

Chapter 6, Coding tutorial, Computer Science, CPP Basics, Exercise Solution, IT Series, Looping Structures, Object Oriented Programming using C++, Programming for beginners, Programming Tutorial

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

Previous Post:
40. Program that uses nested for loops to display multiplication table.

Comments