How To Print V-Shape Pyramid In C
Q. Write a C program to print a V-Shape Pyramid as:
* *
* *
*
Ans.
/*how to print v-shape pyramid in c*/
#include<stdio.h>
int main()
{
int num=3,n,r,c,sp,s;
n=num;
for(r=1; r<=num; r++,n=n-2)
{
for(sp=r; sp>1; sp--)
printf(" ");
printf("*");
for(s=n; s>=1; s--)
printf(" ");
if(r<num)
printf("*");
printf("\n");
}
getch();
return 0;
}
#PROGRAMER_BOY_SHUBHAM
shubhmpandey556@gmail.com
Q. Write a C program to print a V-Shape Pyramid as:
* *
* *
*
Ans.
/*how to print v-shape pyramid in c*/
#include<stdio.h>
int main()
{
int num=3,n,r,c,sp,s;
n=num;
for(r=1; r<=num; r++,n=n-2)
{
for(sp=r; sp>1; sp--)
printf(" ");
printf("*");
for(s=n; s>=1; s--)
printf(" ");
if(r<num)
printf("*");
printf("\n");
}
getch();
return 0;
}
This page is for those student who confused in some C patterns program,...
#PROGRAMER_BOY_SHUBHAM
shubhmpandey556@gmail.com

No comments:
Post a Comment