Friday, October 19, 2007

This Uncomman stuff is cool

i have to face with really unusual stuff with programming with our job interviews. Following shows some examples:

1. Writing hello world without semicolon in C:

#include

int main(){

if(printf("Hello World\n"){

}
}

2. Printing 1 to 100 without using if,for, while or any other loops:

class PrintingWithoutLoopsIf {
public static void main(String args[]){
int z=foo(1);
}
public static int foo(int x) {
System.out.println(x);
x++;
int z=0;
z=(x<101)? foo(x):0;
return 1;
}
}

No comments: