Thursday, 13 October 2011

Pattern in C

Pattern 4:


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





#include<stdio.h>
#include<conio.h>
void main()
{
int x,y,m,s=0,n,p;
clrscr();
printf("Enter the value of n= ");
scanf("%d",&n);
for(x=0;x<n;x++)
{
     for(s=x;s>0;s--)
    {
         printf(" ");
     }
      for(y=x;y<n;y++)
     {
           printf("* ");
      }
    printf("\n");

 m=n-1;;
 p=1;
for(y=x;y<(n*2);y++)
{
          for(s=m;s>=1;s--)
          printf(" ");
    for(x=1;x<=p;x++)
   {
         printf("* ");
    }
 m--;
 p++;
   printf("\n");
 }


 getch();
 }

No comments:

Post a Comment