Q:

Write a program in C++ to print a pattern like highest numbers of columns appear in first row

0

Write a program in C++ to print a pattern like highest numbers of columns appear in first row

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

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

#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;
    }
}

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now