हिंदी

Write a program in C++ to generate and print the following pattern: 1 2 2 3 3 3 4 4 4 4 5 5 5 5 5 - Computer Science 1

Advertisements
Advertisements

प्रश्न

Write a program in C++ to generate and print the following pattern:

1

2  2 

3  3  3

4  4  4  4

5  5  5  5  5

कोड लेखन
Advertisements

उत्तर

#include<iostream.h>
#include<conio.h>
void main()
{
    int i,j;
    for(i=1;i<=5;i++)
    {
        for(j=1;j<=i;j++)
        {
            cout<<i<<" ";
        }
        cout<<"\n";
    }
    getch();
}
shaalaa.com
  क्या इस प्रश्न या उत्तर में कोई त्रुटि है?
2023-2024 (July) Official Board Paper
Share
Notifications

Englishहिंदीमराठी


      Forgot password?
Use app×