Open In App

C++ Program To Print Number Without Reassigning

Last Updated : 25 Aug, 2022
Comments
Improve
Suggest changes
1 Like
Like
Report

Here, we will build a C++ program to print the number pattern without Reassigning using 2 approaches i.e.

  1. Using for loop
  2. Using while loop

1. Using for loop

Input: 

n = 5

Output:

1 
2 3 
4 5 6 
7 8 9 10 
11 12 13 14 15  

The first for loop is used to iterate the number of rows and the second for loop is used to repeat the number of columns. Then print the number and increment the number to print the next number. 


Output
1 
2 3 
4 5 6 
7 8 9 10 
11 12 13 14 15 

2. Using while loop

Input: 

n = 5

Output:

1 
2 3 
4 5 6 
7 8 9 10 
11 12 13 14 15  

The while loops check the condition until the condition is false. If the condition is true then it enters into the loop and executes the statements. 


Output
1 
2 3 
4 5 6 
7 8 9 10 
11 12 13 14 15 

C++ Program To Print Number without reassigning
Practice Tags :

Similar Reads