Stay Tuned!

Subscribe to our newsletter to get our newest articles instantly!

C++ Programming

C++ – Generates Triangle Shape Nested Loop

Generates Triangle Shape Nested Loop

Write a program that generates the following output using a break statement with nested any loop.

1
4
6      9
8      12   16
10           …
12           …
14           …
…
…
..
…
24   36   48   60   72   84   96   108 120 132 144

Source Code:

#include<iostream.h>
#include<conio.h>
void main(){
    int x,y;
    for(x=1;x<=12;x++)
     {
      for(y=1;y<=x;y++)
       {
        cout<<x*y;
        }
        cout<<"n";
        }
        getch();
}

Output:

1
24
369
481216
510152025
61218243036
7142128354249
816243240485664
91827364554637281
102030405060708090100
112233445566778899110121
1224364860728496108120132144

Avatar

Tuts

About Author

Tutsmaster.org provides tutorials related to tech and programmings. We are also setting up a community for the users and students.

You may also like

program to find leap year
C++ Programming

C++ Program to Find Leap Year by Using Function

  • March 3, 2016
Write a program to find if the inputted year is a leap year or not by using the concept of