Q22. Write a program to fill the entire screen with diamond and heart alternatively. [Hint: the ASCII value for heart is 3 and that of diamond is 4]
==> For following program, code goes like this :
/* Program for filling the whole screen with heart or diamond shape */
#include<stdio.h>
int main()
{
int i,j=3,k=4;
for(i=1;i<=5000;i++)
{
if(i%2==0)
{
printf("%c",j);
}
else
{
printf("%c",k);
}
}
return 0;
}
Output:
I have used Dev CPP to compile this program.
If you are using Turbo C++ IDE, then use conio.h in link section after stdio.h
and use getch(); to hold the output screen, just before the end of main function.
If you have any confusion regarding the program, please, comment below.
Happy Coding !
Thank you
Home / C Programs /
filling entire screen with diamond in C /
Heart & Diamond in C
/ Program to fill the entire screen with diamond and heart alternatively in C
- Blogger Comment
- Facebook Comment
Subscribe to:
Post Comments
(
Atom
)
0 comments:
Post a Comment