Chapter 6:
Looping Structures
Programming Exercise
Problem # 51:
Write a program to display the following output using loop:
0
01
012
0123
01234
012345
Solution:
#include<iostream>
#include<conio.h>
using namespace std;
int main()
{
for(int i=0;i<=5;i++)
{
for(int k=0;k<=i;k++)
{
cout<<k;
}
cout<<"\n";
}
getch();
}
#include<conio.h>
using namespace std;
int main()
{
for(int i=0;i<=5;i++)
{
for(int k=0;k<=i;k++)
{
cout<<k;
}
cout<<"\n";
}
getch();
}
Output:
Let me know in the comment section if you have any question.
Previous Post:
50. Program to display the following output using loop.
Comments
Post a Comment