Thursday, July 11, 2013

write a program to print the following ‘*’ pattern ?

    *******
     *****
      ***
       *

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:
image


Like the Post? Do share with your Friends.

No comments:

Post a Comment