Took me almost too long to get this ‘un
This was a ‘puzzle’ mailed by a friend today. It almost made me realize that I’m getting a bit rusty
Fill in the lines of xxxxxxxxx so that this program will print Bingo.
PS: dont Use printf("bingo") and return 0
int main()
{
int a,b;
xxxxxxxxx
xxxxxxxxx
xxxxxxxxx
if ( a==b)
printf("equal");
else
if ( a > b )
printf("greater");
else
if( a < b)
printf("less");
else
printf("Bingo");
return 0;
}
My solution:
int main()
{
int a,b;
if (a = b)
printf("Bingo\n");
else
if ( a==b)
printf("equal");
else
if ( a > b )
printf("greater");
else
if( a < b)
printf("less");
else
printf("Bingo");
return 0;
}
Bejasus!
Advertisement
Here’s another solution that I figured out,
int main()
{
int a,b;
a = 8;
b = 10;
#define a ++a
if ( a==b)
printf(“equal”);
else
if ( a > b )
printf(“greater”);
else
if( a < b)
printf("less");
else
printf("Bingo");
return 0;
}
Gotta love macros right
BTW, this is tested on Visual Studio 2005
Prabhu
December 9, 2009 at 9:22 pm
Sorry, I messed up the indentation…
Prabhu
December 9, 2009 at 9:23 pm
Found two solutions ..
Replace xxxxxxx with 1. #define if(x) if(0) 2. a=3,b=5; #define a a++; #define b b--;Raghu
December 10, 2009 at 2:23 pm
Here’s another one,
if (printf(“Bingo”))
exit(0); //you only said no ‘return’ :p
Prabhu
December 10, 2009 at 4:10 pm