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=n-r; p>=1; p--)
       printf(" ");
   for(a=r; a>=1; a--)
        printf("*");
   for(a=r; a>1; a--)
        printf("*");
   printf("\n");
  }
  getch();
}
Output:
image

Like the Post? Do share with your Friends.

No comments:

Post a Comment