Computer Science, asked by ritunaha, 1 year ago

how to generate the following pattern?
      4
    43
  432
4321

Answers

Answered by Samundeeswari
3
u can use this code to get the pattern...
Attachments:

kvnmurty: :)
kvnmurty: the answer can be simpler .. please see my answer.
Samundeeswari: yeah... but...4 is in the right corner... for this we need to use Spacebar also.. that's what i have done here...
Answered by kvnmurty
2

#include <stdio.h>
main {
    int  row, col;

       for (row=4; row >= 1 ; row--) {
               for (col=4 ; 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 =4 ; col >= row ; col-- )
                          cout << col ;
                   cout << "\n" ;
            }
}

Similar questions