C++ Exercises: Print a pattern like highest numbers of columns appear in first row
C++ For Loop: Exercise-50 with Solution
Write a C++ program to print a pattern in which the highest number of columns appears in the first row.
Pictorial Presentation:

Sample Solution:
C++ Code :
#include <iostream>
using namespace std;
int main()
{
int i, j, n;
cout << "\n\n Display the pattern like highest numbers of columns appear in first row:\n";
cout << "------------------------------------------------------------------------------\n";
cout << " Input the number of rows: ";
cin >> n;
for (i = 1; i <= n;)
{
cout << i;
for (j = i + 1; j <= n;)
{
cout << j;
j = j + 1;
}
cout << endl;
i = i + 1;
}
}
Sample Output:
Display the pattern like highest numbers of columns appear in first row: ------------------------------------------------------------------------------ Input the number of rows: 5 12345 2345 345 45 5
Flowchart:

C++ Code Editor:
Contribute your code and comments through Disqus.
Previous: Write a program in C++ to print a pyramid of digits as shown below for n number of lines.
Next: Write a program in C++ to display the pattern using digits with right justified and the highest columns appears in first row.
What is the difficulty level of this exercise?
- Weekly Trends
- Python Interview Questions and Answers: Comprehensive Guide
- Scala Exercises, Practice, Solution
- Kotlin Exercises practice with solution
- MongoDB Exercises, Practice, Solution
- SQL Exercises, Practice, Solution - JOINS
- Java Basic Programming Exercises
- SQL Subqueries
- Adventureworks Database Exercises
- C# Sharp Basic Exercises
- SQL COUNT() with distinct
- JavaScript String Exercises
- JavaScript HTML Form Validation
- Java Collection Exercises
- SQL COUNT() function
- SQL Inner Join