51. Program to display the following output using loop.

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();
}

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

Comments