Computer Science, asked by ritunaha, 1 year ago

1234
  123
    12
      1
how to generate the above pattern

Answers

Answered by Samundeeswari
1
this code can generate:)
Attachments:

kvnmurty: the program can be as simple as shown in my answer. i request you to see that.
Samundeeswari: yeah...i saw urs... according to ur code we'll get the output in the left corner... output somewhat varies from the qn given...
kvnmurty: in the question the numbers are to the left side only... as i see them on the top of the question... the numbers are not centered..
Answered by kvnmurty
2
#include <stdio.h>
main {
    int  row, col;

       for (row=4; row >= 1 ; row--) {
               for (col=1 ; col <= row ; col++) 
                    printf("%d",col);
               printf("\n");
       }
}

===========================
C Plus Plus

#include <iostream>
using namespace std;

int main()
{
       int row, col;
        
            for (row=4; row >=1 ; row--) {
                   for (col =1 ; col <= row ; col++ )
                          cout << col ;
                   cout << "\n" ;
            }
}
Similar questions