C Language Programs to print Number patterns











Program to print number 9 in C Language without Graphics

// Program to print number 9 in C language with CBhashaGyan

#include<stdio.h>

int main()

{

int i, j;

for (i=1; i<=7; i++)

{

    printf("\t");                //for horizontal tab

    for(j=1; j<=4; j++)
   
     {

       if((j==4) && (i!=1 && i!=7))

       printf("* ");

       else if(j==1 && (i==2 || i==3 || i==6))

       printf("* ");

       else if((i==1 || i==4 || i==7) && j>=2 && j<=3)

       printf("* ");      //star and space

       else
    
       printf("  ");        //double space

    }

   printf("\n");          //new line

}

return 0;

}

Output:


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

Practical demonstration in Pictorial form-


Program to print number 9 in C Language without Graphics
Program to print number 9 in C Language without Graphics

Output:-

Program to print number 9 in C Language without Graphics Output
Program to print number 9 in C Language without Graphics Output

Program to print number 8 in C Language without Graphics

// Program to print number 8 in C language with CBhashaGyan

#include<stdio.h>

int main()

{

int i, j;

for (i=1; i<=7; i++)

{

    printf("\t");                //for horizontal tab

    for(j=1; j<=4; j++)
   
     {

       if((j==1 || j==4) && (i!=1 && i!=4 && i!=7))

       printf("* ");

       else if((i==1 || i==4 || i==7) && j>=2 && j<=3)

       printf("* ");      //star and space

       else
    
       printf("  ");        //double space

    }

   printf("\n");          //new line

}

return 0;

}

Output:


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

Practical demonstration in Pictorial form-


Program to print number 8 in C Language without Graphics
Program to print number 8 in C Language without Graphics

Output:-

Program to print number 8 in C Language without Graphics Output
Program to print number 8 in C Language without Graphics Output

Program to print number 7 in C Language without Graphics

// Program to print number 7 in C language with CBhashaGyan

#include<stdio.h>

int main()

{

int i, j;

for (i=1; i<=5; i++)

{

    printf("\t");                //allow horizontal tab

    for(j=1; j<=5; j++)
   
     {

       if(i==1 && j<=3)

       printf("* ");      //star and space

       else if((i==3 && (j==2 || j==4)) || ( j==5-i+1 && i>=2))

       printf("*");      //allow star

       else
    
       printf("  ");        //double space

    }

   printf("\n");          //new line

}

return 0;

}

Output:


*  *  *
     *
  ***
  *         
*  
         

Practical demonstration in Pictorial form-


Program to print number 7 in C Language without Graphics
Program to print number 7 in C Language without Graphics

Output:-

Program to print number 7 in C Language without Graphics Output
Program to print number 7 in C Language without Graphics Output

Program to print number 6 in C Language without Graphics

// Program to print number 6 in C language with CBhashaGyan

#include<stdio.h>

int main()

{

int i, j;

for (i=1; i<=7; i++)

{

    printf("\t");                //for horizontal tab

    for(j=1; j<=4; j++)
   
     {

       if(j==1 && i!=1 && i!=7)

       printf("* ");      //allow star and space

       else if(j==4 && (i==2 || i==5 || i==6))

       printf("* ");      //allow star and space

       else if((i==1 || i==4 || i==7) && j>=2 && j<=3)

       printf("* ");      //allow star and space
        
       else
    
       printf("  ");        //for double space

    }

   printf("\n");          //for new line

}

return 0;

}


Output:


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

Practical demonstration in Pictorial form-


Program to print number 6 in C Language without Graphics
Program to print number 6 in C Language without Graphics

Output:-

Program to print number 6 in C Language without Graphics Output
Program to print number 6 in C Language without Graphics Output

Program to print number 5 in C Language without Graphics

// Program to print number 5 in C language with CBhashaGyan

#include<stdio.h>

int main()

{

int i, j;

for (i=1; i<=7; i++)

{

    printf("\t");                //for horizontal tab

    for(j=1; j<=4; j++)
   
     {

       if( i==1 || (j==4 && ( i==5 || i==6)))

       printf("* ");      //to allow star with space

       else if(j==1 && ( i!=1 && i!=5 && i!=7))

       printf("* ");      //to allow star with space

       else if((i==4 || i==7) && j>=2 && j<=3)

       printf("* ");      //allow star with space
        
       else
    
       printf("  ");        //for double space

    }

   printf("\n");          //for new line

}

return 0;

}


Output:


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

Practical demonstration in Pictorial form-


Program to print number 5 in C Language without Graphics
Program to print number 5 in C Language without Graphics

Output:-

Program to print number 5 in C Language without Graphics Output
Program to print number 5 in C Language without Graphics Output

Program to print number 4 in C Language without graphics

// Program to print number 4 in C language with CBhashaGyan

#include<stdio.h>

int main()

{

int i, j;

for (i=1; i<=5; i++)

{

    printf("\t");                //for horizontal tab

    for(j=1; j<=3; j++)
   
     {

       if((j==1 && i<=3) || j==3 || i==3)

       printf("* ");      //for star with space

       else

       printf("  ");        //for double space

    }

   printf("\n");          //for new line

}

return 0;

}

Output:


*       *
*       *
*  *   *
        *
        *
         

Practical demonstration in Pictorial form-


Program to print number 4 in C Language without graphics
Program to print number 4 in C Language without graphics

Output:-

Program to print number 4 in C Language without graphics output
Program to print number 4 in C Language without graphics output