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!

Advertisements
Took me almost too long to get this ‘un

4 thoughts on “Took me almost too long to get this ‘un

  1. 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

    Like

Speak your mind!

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s