Search This Blog

Translate

C Program Pattern Examples with source code.

C Program Pattern Examples,C Program Print  Pattern Examples with source code. solve c programming pattern example with pattern image ,print different pattern using c programming







# include
# include
void main ()
{
int i,j,n;
clrscr ();
for(i=1;i<=5;i++)
{
n=1;
for(j=1;j<=i;j++)
{
if(j%2==0)
printf("#");
else
printf("?");
}
printf("\n");
}
getch();
}










# include
# include
void main ()
{
int i,j,s;
clrscr ();
  for(i=1;i<=4;i++)
  {
  for(s=4;s>=i;s--)
  {
  printf(" ");
  }
  for(j=1;j<=i;j++)
  {
  if(i%2==0)
  {
  printf(" #");
  }
  else
  printf(" *");
 }
     printf("\n");
  }


  getch();
  }











#include
#include
void main()
{
char x,y;
clrscr();
for(x='D';x>='A';x--)
{
for(y='A';y<=x;y++)
{
printf("%c",y);
}
printf("\n");
}
getch();
}










#include
#include
void main()
{
char x,y;
clrscr();
for(x='a';x<='d';x++)
{
for(y='a';y<=x;y++)
{
printf("%c",y);
}
printf("\n");
}
getch();
}








# include
# include
void main ()
{
int i,j;
char x;
clrscr ();
for(i=5;i>0;i--)
{x='A';
for(j=1;j<=i;j++)
{
if(i%2==0)
{
 printf("%c",x);
 x++;
 }
 else
 {
 printf("%c",x+32);
 x++;
 }

 }
  printf("\n");
  }
  getch();
  }

 

 #include
#include
void main()
{
int x,y;
clrscr();
for(x=1;x<=4;x++)
{
for(y=1;y<=4;y++)
{

printf("*");
}
printf("\n");
}
        getch();
}

 

 #include
#include
void main()
{
int x,y;
clrscr();
for(x=1;x<=4;x++)
{
for(y=1;y<=x;y++)
{

printf("*");
}
printf("\n");
}
getch();
}

 

 

 

#include
#include

void main()
{
int i,j,z,x=4,t,p=0,q=4;
clrscr();
for(i=1;i<=4;i++)
{
   for(t=1;t<=x;t++)
  {
     printf("%d",t);
    }
    for(z=1;z<=p;z++)
      {
         printf(" ");
  //      printf("\b");
    }
 for(j=q;j<=7;j++)
  {
   printf("%d",j);
  }
  printf("\n");
  p=p+2;
  x--;
  q++;
  }
 getch();
 }

 

#include
#include
void main()
{
int x,y;
clrscr();
for(x=4;x>=1;x--)
{
for(y=1;y<=x;y++)
{

printf("%d",y);
}
printf("\n");
}
getch();
}

 

 #include
#include
void main()
{
int x,y;
clrscr();
for(x=1;x<=4;x++)
{
for(y=1;y<=x;y++)
{

printf("%d",y);
}
printf("\n");
}
getch();
}

# include
# include
void main ()
{
int i,j,n;
clrscr ();
for(i=1;i<=5;i++)
{
n=1;
for(j=1;j<=i;j++)
{
printf("%d",n);
n=n+2;
}
printf("\n");
}
getch();
}

# include
# include
void main ()
{
int i,j,x=13,y=11;
clrscr ();
for(i=4;i>0;i--)
{
for(j=1;j<=i;j++)
{
if(i==4)
{
 printf(" %d",x);
 x=x+2;
 }
 else
 {
 printf(" %d",y);
 y=y-2;
 }

 }
  printf("\n");
  }
  getch();
  }


C Pattern Examples to print Diamond


 
# include
# include
void main ()
{
int i,j,k,s,t=5,x,a;
clrscr ();
printf("how many dimond you want to see");
scanf("%d",&x);
for(a=1;a<=x;a++)
{
printf("\n\n\n");
for(i=1;i<=5;i++)
{
for(s=1;s{
printf(" ");
}
for(j=1;j<=i;j++)
{
printf(" *");
}
printf("\n");
t--;
}
t=1;
for(i=4;i>=1;i--)
{
for(s=1;s<=t;s++)
{
printf(" ");
}
for(j=1;j<=i;j++)
{
printf(" *");
}
printf("\n");
t++;
}
}
  getch();
  }
 





# include
# include
void main ()
{
char i,j,s,t=0,d;
clrscr();
for(i=5;i>=1;i--)
{
for(d=1;d<=i;d++)
{
printf("*");
}

 for(s=0;s {
 printf(" ");
 }
 for(j=1;j<=i;j++)
 {
 printf("*");
 }
 t=t+2;
 printf("\n");
}
t=6;
for(i=2;i<=5;i++)
{
for(d=1;d<=i;d++)
{
printf("*");
}
for(s=1;s<=t;s++)
{
printf(" ");
}
for(j=1;j<=i;j++)
{
printf("*");
}
        printf("\n");
   t=t-2;
}
getch();
}





# include
# include
void main ()
{
int i,j,s,t=5;
clrscr ();
for(i=1;i<=7;i=i+2)
{
for(s=1;s{
printf(" ");
}
for(j=1;j<=i;j++)
{
if(j%2==0)
printf("*");
else
printf("#");
}
printf("\n");
t--;
}
getch();
}







 

 

C Program example List

Google+ Badge