*******
*****
***
*
Program:
#include<stdio.h>
#include<conio.h>
void main()
{
int n,r,a,p;
clrscr();
printf(" enter the no of rows ");
scanf("%d",&n);
for(r=1;r<=n; r++)
{
for(p=r; p>=1; p--)
printf(" ");
for(a=1; a<=n-r;a++)
printf("*");
for(a=n-r-1; a>=1; a--)
printf("*");
printf("\n");
}
getch();
}
Output:
*****
***
*
Program:
#include<stdio.h>
#include<conio.h>
void main()
{
int n,r,a,p;
clrscr();
printf(" enter the no of rows ");
scanf("%d",&n);
for(r=1;r<=n; r++)
{
for(p=r; p>=1; p--)
printf(" ");
for(a=1; a<=n-r;a++)
printf("*");
for(a=n-r-1; a>=1; a--)
printf("*");
printf("\n");
}
getch();
}
Output:
No comments:
Post a Comment