Patterns Program Using C Language

The below article consists of different patterns that can be generated using C programs.

Code-1:
#include<stdio.h>
 void main(){
 int i,j,k;
 int c=1,v=0;
 for(i=1;i<=9;i++){
 if(i%2!=0){
 for(j=i;j<=9;j++)
 {
 printf(" ");
 }
 for(k=1;k<=i;k++){
 c++;
 if(c%2!=0){printf("1 ");
 }
 else if(v==0) {
 printf("1 ");
 v++;}
 else{
 printf("0 ");      }
 }    printf("\n");c=0;}
 }
 }

OUTPUT:

 

 

CODE 2:
#include<stdio.h>
 void main(){
 int i,j,k;
 for(i=1;i<=6;i++){
 for(j=1;j<=i;j++){
 printf("*",j);
 }
 printf("\n");
 }}

OUTPUT:

 

 

 

Code 3:
#include<stdio.h>
void main(){
int i,j,k,count=0;
for(i=1;i<=8;i++){
for(j=i;j<=8;j++){
printf(" ");
}
for(k=1;k<=i;k++){
printf("%d ",k);
}
printf("\n");count=0;
}

}

OUTPUT:

 

 

 

 

CODE 4:
#include<stdio.h>
void main(){
int i,j;
for(i='A';i<='J';i++)
{
for(j='A';j<=i;j++)
{
printf("%c",j);
}   printf("\n");
}}

OUTPUT:

 

 

 

 

 

Code 5:

#include<stdio.h>
void main(){
int i,j,k,l,c;
for(i='A';i<='J';i++){
for(j=i;j<='J';j++){
printf(" ");
}
for(k='A';k<=i;k++){
printf("%c",k);
}
for(l=i-1;l>='A';l--){printf("%c",l);}
printf("\n");
}

}

OUTPUT:

 

 

 

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.