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

  • برمجة سي بلس بلس
  • برمجة

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

الأجوبة

#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;
    }
}
هل كان المحتوى مفيد؟

تبحث عن مدرس اونلاين؟

محتاج مساعدة باختيار المدرس الافضل؟ تواصل مع فريقنا الان لمساعدتك بتأمين افضل مدرس
ماهو التخصص الذي تبحث عنه؟
اكتب هنا...