Program to print number 1 in C Language without Graphics

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

#include<stdio.h>

int main()

{

int i, j;

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

{

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

       if(i==5 || j==3)

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

       else if( i==2 && j==2)
   
       printf("* ");                   //star and space

       else

       printf("  ");        // double space

    }

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

}

return 0;

}

Output:


      *
   * *
     *
     *
* * * * *
         

Practical demonstration in Pictorial form-


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

Output:-

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

Program to print alphabet in C Language without Graphics

//Program to print alphabet in C Language without Graphics.

#include<stdio.h>

#include<conio.h>

void A(); void B(); void C(); void D(); void E(); void F(); void G();

void H(); void I(); void J(); void K(); void L(); void M(); void N();

void O(); void P(); void Q(); void R(); void S(); void T(); void U();

void V(); void W(); void X(); void Y(); void Z();

int main()

{

char choice;

clrscr();   //to clear the screen or display 

label:

printf("Enter a character from A to Z which you want to print\n");

scanf("%c", &choice);

switch(choice)

{

case 'A': case 'a': A(); break;

case 'B': case 'b': B(); break;

case 'C': case 'c': C(); break;

case 'D': case 'd': D(); break;

case 'E': case 'e': E(); break;

case 'F': case 'f': F(); break;

case 'G': case 'g': G(); break;

case 'H': case 'h': H(); break;

case 'I': case 'i': I(); break;

case 'J': case 'j': J(); break;

case 'K': case 'k': K(); break;

case 'L': case 'l': L(); break;

case 'M': case 'm': M(); break;

case 'N': case 'n': N(); break;

case 'O': case 'o': O(); break;

case 'P': case 'p': P(); break;

case 'Q': case 'q': Q(); break;

case 'R': case 'r': R(); break;

case 'S': case 's': S(); break;

case 'T': case 't': T(); break;

case 'U': case 'u': U(); break;

case 'V': case 'v': V(); break;

case 'W': case 'w': W(); break;

case 'Y': case 'y': Y(); break;

case 'Z': case 'z': Z(); break;

default: printf("please enter only A to Z alphabet..."); goto label;

}

return 0;

}

//Program for A

void A()

{

int i, j, k;

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

{

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

    printf (" ");

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

    {

       if(i>3 && (j>1 && j<i))   // for middle star

       printf("  ");        // allow double space

       else

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

    }

   printf("\n");

}}


//Program for B

void B()

{

int i, j;

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

  {

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

    {

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

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

      else if((i==2 || i==4) && (j==1 || j==4))

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

      else

      printf("  ");  // double space

    }

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

  }

}


//Program for C

void C()

{

int i, j;

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

 {

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

    {

      if((i==1 || i==5) && (j==2 || j==3))

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

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

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

      else

      printf("  ");         //double space

    }

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

 }

}


//Program for D

void D()

{

 int i, j;

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

  {

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

     {

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

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

      else if((i==2 || i==4) && (j==1 || j==4))

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

      else if( i==3 && (j==1 || j==4))

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

      else

      printf("  ");         //double space

     }

    printf("\n");

  }

}


//Program for E

void E()

{

 int i, j;

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

  {

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

    {

     if(i==1 || i==5 || j==1)

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

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

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

     else

     printf("  ");        //double space

     }

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

  }

}


//Program for F()

void F()

{

  int i, j;

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

   {

     printf("\t");         //for Horizontal Tab

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

      {

if(i==1 || j==1)

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

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

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

else

printf("  ");      //double space

      }

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

   }

}


//Program for G()

void G()

{

 int i, j;

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

  {

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

    {

     if((i==1 || i==6) && (j>=2 && j<=4))

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

     else if(i>=2 && i<=5 && j==1)

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

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

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

     else

     printf("  ");        //double space

    }

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

  }

}


//Program for H()

void H()

{

 int i, j;

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

  {

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

    {

      if(i==1 || i==4 || i==3)

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

      else

      printf("  ");        //double space

    }

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

  }

}

//Program for I

void I() 

 {

  int i, j;

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

   {

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

     {

       if( i==1 || i==5 || j==3)

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

       else

       printf("  ");        // double space

     }

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

   }

 }

//Program for J

void J() 

{

 int i, j;

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

  {

    printf("\t");           // for Horizontal Space

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

     {

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

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

       else if( i==6 && j>=1 && j<=3)

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

       else

       printf("  ");        // double space

     }

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

  }

}

//Program for K

void K() 

{

 int i, j;

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

  {

    printf("\t");           // for Horizontal Space

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

     {

       if( j==1 || (j==2 && i%2==0))

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

       else if( j==3 && (i==1 || i==5))

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

       else

       printf("  ");        // double space

     }

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

  }

}

//Program for L

void L() 

{

 int i, j;

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

  {

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

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

    {

      if(i==5 || j==1)

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

      else

      printf("  ");        //double space

    }

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

  }

}

//Program for M

void M() 

{

 int i, j;

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

  {

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

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

    {

      if(j==1 || j==5)

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

      else if((i==j || j==5-i+1) && i<=3)

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

      else

      printf("  ");        //double space

   }

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

  }

}

//Program for N

void N() 

{

 int i, j;

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

  {

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

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

    {

      if((j==1 || j==5) || i==j)

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

      else

      printf("  ");        //double space

    }

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

 }

}

//Program for O

void O() 

{

 int i, j;

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

  {

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

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

    {

      if((i==1 || i==5) && (j==2 || j==3))

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

      else if((i==2 || i==4) && (j==1 || j==4))

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

      else if(i==3 && (j==1 || j==4))

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

      else

      printf("  ");        //double space

    }

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

  }

}

//Program for P

void P() 

{

 int i, j;

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

  {

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

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

    {

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

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

      else if(j==1 || (i==2 && j==4))

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

      else

      printf("  ");        //double space

    }

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

  }

}

//Program for Q

void Q() 

{

 int i, j;

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

  {

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

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

    {

      if((i==1 || i==5) && (j>=2 && j<=4))

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

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

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

      else if(i>=4 && i==j)

      printf("*");        //star

      else

      printf("  ");        //double space

    }

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

  }

}

//Program for R

void R() 

{

 int i, j;

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

  {

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

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

     {

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

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

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

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

       else if(i==2 && j==4)

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

       else

       printf("  ");        // double space

     }

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

  }

}

//Program for S

void S() 

{

 int i, j;

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

  {

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

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

    {

      if((i<=4 && j==1 && i!=1) || (i>5 && j==4 && i!=9))

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

      else if((i==1 || i==5 || i==9) && (j>=2 && j<=3))

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

      if((i==2 && j==4) || (i==8 && j==1))

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

      else

      printf("  ");        //double space

    }

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

 }

}

//Program for T

void T() 

{

 int i, j;

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

  {

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

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

    {

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

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

      else

      printf("  ");        //double space

   }

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

 }

}

//Program for U

void U() 

{

 int i, j;

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

  {

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

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

    {

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

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

      else if( i==5 && (j==2 || j==3))

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

      else

      printf("  ");        //double space

    }

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

  }

}

//Program for V

void V() 

 {

  int i, j, k;

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

   {

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

    printf (" ");              // allow single space

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

     {

       if( j==i || j==5)   // for 1st and last position

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

       else

       printf("  ");        // allow double space

     }

    printf("\n");

   }

}

//Program for W

void W() 

{

 int i, j;

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

  {

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

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

    {

      if(j==1 || j==5)

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

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

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

      else

      printf("  ");        //allow double space

    }

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

  }

}

//Program for X

void X() 

{

 int i, j;

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

  {

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

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

     {

       if( i==j || j==5-i+1)

       printf("*");        // allow star

       else

       printf(" ");        // allow space

     }

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

  }

}

//Program for Y

void Y() 

{

 int i, j;

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

  {

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

    for(j=1; j<=6; j++)

     {

       if(( i==j && i<=3) || j==6-i+1)

       printf("*");        // for star

       else

       printf(" ");        // for single space

     }

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

  }

}

//Program for Z

void Z() 

{

  int i, j;

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

   {

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

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

      {

       if( (i==1 || i==5 ) || j==5-i+1)

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

       else

       printf("  ");        // allow double space

      }

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

   }

}


Output:-

Program to print alphabet in C Language without Graphics
Program to print alphabet in C Language without Graphics


⏪ Program to Print Alphabet Z                                                                      Program List to Print Alphabet ⏩

Program to print alphabet Z in C Language without Graphics

// Program to print alphabet Z in C with C Bhasha Gyan

#include<stdio.h>

int main()

{

int i, j;

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

{

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

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

       if( (i==1 || i==5 ) || j==5-i+1)

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

       else

       printf("  ");        // allow double space

    }

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

}

return 0;

}


Output:


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

Practical demonstration in Pictorial form-


Program to print alphabet Z in C Language without Graphics
Program to print alphabet Z in C Language without Graphics

Output:-

Program to print alphabet Z in C Language without Graphics Output
Program to print alphabet Z in C Language without Graphics Output

⏪ Program to Print Alphabet Y                                                       Complete Program to Print Alphabet ⏩

Variable in C Language

Hello viewer in this page we will discuss with more about the variable with practical knowledge. Till now we have covered the variable declaration rules with some examples in Token section.

For complete understanding the variable we have some more questions like

  • how to declare variable
  • how to initialize variable
  • how to use variable
  • how variable behave differently due to storage classes.

Variable Declaration in C Language- 

To declare a variable we have to follow the syntax of variable declaration given below-

Data_Type Variable_Name;

Data_Type illustrate about the variable storing ability means which kind of value variable can hold and about variable capacity(int variable capacity is of 2 Byte).

Variable_Name illustrate the name of variable or the location name inside the memory through which processor can get the address and fetch the value from that address. It must follow the variable naming rules which we have already covered.

Example: int a;

here int is a data type that illustrate the ability of integer valued and 2 Byte capacity and a is a variable name which hold the address in memory of 2 Byte for storing integer values.

Variable Initialization in C Language-

To initialize variable we have to follow the Syntax of variable initialization in two cases-

1. Initialization at the time of variable declaration-

Data_Type Variable_Name = Value ;

Example: int a=5;

Here value 5 is directly assigned to variable a at the time of variable declaration. 

2. Initialization after Variable Declaration-

Data_Type Variable_Name;

Variable_Name = Value;

Here first we declare a Variable with Variable_Name and then in next instruction we have to assign a value to it.

Example: int a;

a=5;

How to use Variable in C Language-

When we are writing code in C Language or other programming language we have to make variable name must be familiar with that program means meaningful name must be used.
Example: when we are writing a program for simple interest the variable name must be familiar with program like Price, Rate, Time, S_Interest not like a,b,c,d. Name of Variable must be familiar with program although there will be no error by compiler but for good practice every programmer should follow this.

Now let us take an example to understand variable completely by adding two values-

#include<stdio.h>

int main()

{
 
    int a=6,b=7,c; //int is datatype for 2 Byte integer values and a,b and c are integer variable.

    c=a+b;

    printf("c=%d", c);   // processor fetch the value from memory location name is c.

    return 0;

}  

Output:-

c=13

Memory Mapping-

Variable Allocation
variable allocation

c variable name 13 storing value at the assuming address of 65523.

Storage Class in C Language➤ 

Program to print alphabet Y in C Language without Graphics

// Program to print alphabet Y in C with C Bhasha Gyan

#include<stdio.h>

int main()

{

int i, j;

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

{

    printf("\t");              //for horizontal tab
   
    for(j=1; j<=6; j++)
   
     {

       if(( i==j && i<=3) || j==6-i+1)

       printf("*");        // for star

       else

       printf(" ");        // for single space

    }

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

}

return 0;

}


Output:


*        *
  *    *
    **
    *
  *
*

         

Practical demonstration in Pictorial form-


Program to print alphabet Y in C Language without Graphics
Program to print alphabet Y in C Language without Graphics

Output:-

Program to print alphabet Y in C Language without Graphics Output
Program to print alphabet Y in C Language without Graphics Output

⏪ Program to Print Alphabet X                                                               Program to Print Alphabet Z⏩

Program to print alphabet X in C Language without Graphics

// Program to print alphabet X in C with C Bhasha Gyan

#include<stdio.h>

int main()

{

int i, j;

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

{

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

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

       if( i==j || j==5-i+1)

       printf("*");        // allow star

       else

       printf(" ");        // allow space

    }

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

}

return 0;

}


Output:


*        *
  *    *
     *
  *    *
*        *
         

Practical demonstration in Pictorial form-


Program to print alphabet X in C Language without Graphics
Program to print alphabet X in C Language without Graphics


Output:-

Program to print alphabet X in C Language without Graphics Output
Program to print alphabet X in C Language without Graphics Output

⏪ Program to Print Alphabet W                                                               Program to Print Alphabet Y⏩

Program to print alphabet T in C Language without Graphics

//Program to print alphabet T 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<=5;j++)

    {

      if(i==1 || j==3)
   
      printf(" *");        //space and star

      else

      printf("  ");        //double space


   }

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

}

return 0;
}


Output:-


*  *  *  *  *
       *
       *
       *
       *

Practical demonstration in Pictorial form-


Program to print alphabet T in C Language without Graphics
Program to print alphabet T in C Language without Graphics

Output:-

Program to print alphabet T in C Language without Graphics Output
Program to print alphabet T in C Language without Graphics Output

⏪ Program to Print Alphabet S                                                               Program to Print Alphabet U⏩