Friday, July 28, 2006

Fill the screen with a smiling face

Write a program to fill the entire screen with a smiling face.
The smiling face has an ASCII value 1.

Other ideas..
An infinite loop like the following can also do the job.
for (i=1;i<=1000;)

#include<stdio.h>

main()
{
int i, j;

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

{
printf("%c", i);
}
}


10 comments:

friend said...

shall i know the logic that why u have used 5000

Nishant said...

That 5000 is just the approx number of smiley 2 avoid indefinite loop.

narendra said...
This comment has been removed by the author.
narendra said...

this following progam also displays smiling face very clearly try it once

#include
main()
{
int i;
for(i=0;i<=2559;i++)
{
printf("%c",2);
}
}

narendra said...

this following progam also displays smiling face very clearly try it once

#include
main()
{
int i;
for(i=0;i<=2559;i++)
{
printf("%c",2);
}
}

Anonymous said...

plz tell how int is converted to char and why 2 is used?

akshay said...

u cn use any int instead of 2 dats jst for wat u wanna print on screen.n char is nt used becoz u hve only integars hve dis smilin faces ascii..char has 66 77 like ascii value

Nithya D said...

i tried all your prpgram .when i compiled my program there was no error and when i moved to the output in the terminal the smiling faces doesnt appear but instead it leaves some space

rajesh choudhary said...

sir can we write like this......
#include
#include
void main ()
{
int i,j;
for(i=1;i<=5000;i++)
{
for(j=1;j<=i;j++)
printf("\n 1" );
}
getch();
}

rajesh choudhary said...

sir can we write like this......
#include
#include
void main ()
{
int i,j;
for(i=1;i<=5000;i++)
{
for(j=1;j<=i;j++)
printf("\n 1" );
}
getch();
}