C Program to Print Character Diamond

CWC
1 Min Read

C Program to print character diamond. This is my code to print all the characters of the alphabet as a character diamond. I have used the ASCII table to find the characters and then used printf to print them. The following is my C program that prints the character diamond. It is based on the ASCII table.

What a great way to teach beginner computer programming is to show the characters being printed. You don’t need to code to make this happen! All you need is a printer and some character art. This is a great way to introduce kids to computer programming while having fun at the same time!



# include <conio.h>
main( )
{
char i,j,n,r;
int s,sp=40;
clrscr( );
for(i=65;i<=75;i+=2)
{
for(s=1;s<=sp;s++)
printf(“ “);
for(j=65;j<i;j++)
printf(“%c”,j);
printf(“\n”);
sp=sp-2;
}
sp=sp+4;
for(n=73;n>=65;n-=2)
{
for(s=1;s<=sp;s++)
printf(“ “);
for(r=65;r<=n;r++)
printf(“%c”,r);
sp=sp+2;
}
getch( );
}

Share This Article
Leave a comment

Leave a Reply

Your email address will not be published. Required fields are marked *

English
Exit mobile version