//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 |