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

Chapter 6: 

Looping Structures

Programming Exercise

Problem # 40:

Write a program that uses nested for loops to display multiplication table as follows:
    1    2     3      4      5
    2    4     6      8      10
    3    6     9      12    15
    4    8     12    16    20
    5    10   15    20    25

Solution:

#include<iostream>
#include<conio.h>
using namespace std;
int main()
{
    for(int i=1;i<=5;i++)
    {
      
        for(int j=1;j<=5;j++)
        {
        cout<<i*j<<"\t";  
        }
      
        cout<<"\n";      
    }
    getch();
}

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:
39. Program to display the following output using loop.

Comments