![]() |
Here, we will build a C++ program to print the number pattern without Reassigning using 2 approaches i.e.
1. Using for loopInput: 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. C++
Output
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 2. Using while loopInput: 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. C++
Output
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
Reffered: https://www.geeksforgeeks.org
C++ |
Type: | Geek |
Category: | Coding |
Sub Category: | Tutorial |
Uploaded by: | Admin |
Views: | 12 |