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();
}
#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:
Let me know in the comment section if you have any question.
Previous Post:
39. Program to display the following output using loop.
Comments
Post a Comment