Tuesday, May 8, 2007

#48

1. Printing "Hello World" without using a single semi colon in C:

Answer:

    This is an age old problem, and most people have known it by now.

    main(){if(printf("hello world")){}}

    check I havnt used a semi colon :D

2. Ever thought of finding the greatest of 2 numbers without using using any comparison operators ?


Answer:

    Same old problem. Basically a little maths:

    a = 10;
    b = 5;

    c = [(a + b) + abs(a - b)]/2;// c will hold the greater of a and b
    d = [(a + b) - abs(a - b)]/2;// d will hold the lesser of a and b

No comments: