Talking with a Lisp

Technical z0ltanspeak

Took me almost too long to get this ‘un

with 4 comments

This was a ‘puzzle’ mailed by a friend today. It almost made me realize that I’m getting a bit rusty :D

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

Written by Timmy Jose

December 9, 2009 at 4:19 pm

Posted in Uncategorized

4 Responses

Subscribe to comments with RSS.

  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

    Prabhu

    December 9, 2009 at 9:22 pm

  2. Sorry, I messed up the indentation…

    Prabhu

    December 9, 2009 at 9:23 pm

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

  4. Here’s another one,

    if (printf(“Bingo”))
    exit(0); //you only said no ‘return’ :p

    Prabhu

    December 10, 2009 at 4:10 pm


Leave a Reply

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 )

Connecting to %s

Follow

Get every new post delivered to your Inbox.

Join 45 other followers