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;;
}
}
#include<conio.h>
using namespace std;
int main()
{
for(int i=1;i<=4;i++)
{
cout<<i<<" "<<2<<" "<<4<<" "<<6<<endl;;
}
}
Output:
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
Post a Comment