Write a program to draw the following figure: 3 2 1 21 1 * ** ***

 1)
      3 2 1 

      21

     1

Code:-


#include<stdio.h>

int main()
{
int i,j,x;
for(i=3;i>=1;i–)
{
x=i;
for(j=1;j<=i;j++)
{
printf(“%d”,x);
x–;
}
printf(“n”);
}
return 0;
}

Output:-


321
21
1

2)

  * 

  **

 ***

Code:-

#include<stdio.h>

int main()
{
int i,j;
for(i=1;i<=3;i++)
{
for(j=1;j<=i;j++)
{
printf(“*”);
}
printf(“n”);
}
return 0;
}

Output:-

*
**
***



Leave a Reply

Your email address will not be published.