• Courses
  • Tutorials
  • Jobs
  • Practice
  • Contests
September 14, 2022 |770 Views
C++ Program To Print Number without reassigning
  Share   Like
Description
Discussion

In this video, we will write a C++ program to print the number pattern without Reassigning.

Examples:
Input: n = 3

Output:
1
2 3
4 5 6

Here we see 2 different methods for printing numbers without reassigning:

1. Using for loop
2. Using While loop

1. Using for loop:
Step 1: Take input N from the user.
Step 2: Now take two for loops. Here first for loop is used to iterate the number of rows and the second for loop is used to repeat the number of columns.
Step 3: Print the number and increment the number to print the next number.
Step 4: Stop

2. Using while loop:
Step 1: Take the input N from the user.
Step 2: Take a while loop and check the condition until the condition becomes false.
Step 2.1: If the condition is true then it enters into the loop and executes the statements, and prints the number to get the required pattern.
Step 2.2: If the condition is false then the loop is terminated.
Step 3. Stop

C++ program to print the number pattern without Reassigning: https://www.geeksforgeeks.org/cpp-program-to-print-number-without-reassigning/

Read More