Centipedes and programming A survey
This is a survey. Read this post for as long as your interest holds, and then go to the last part, where you can find out who you really are!
Here’s a groaner:
Q) What did the male centipede say when it saw a female centipede it liked?
A) What a beautiful pair of legs.. a beautiful pair of legs.. a beautiful pair of legs…
Now here comes something worse: (Don’t say you were not warned!)
Q) What did the male programmer centipede do, when it saw a female centipede it liked?
A) It wrote the following program:
<pre>
int main(){
int i=0;
for(i=1;i<101;i++){
printf("What a beautiful pair of legs!\n");
}
return(0);
}
</pre>
Still reading ? Here’s some more!
Q) What did the male programmer centipede which was particular about its code do, when it saw a female centipede it liked?
A) It wrote the following program:
<pre>
int main(){
int i=0;
for(i=1;i<101;i++){
switch(i%10){
case 1:
printf("What a beautiful %dst pair of legs!\n",i);
break;
case 2:
printf("What a beautiful %dnd pair of legs!\n",i);
break;
case 3:
printf("What a beautiful %drd pair of legs!\n",i);
break;
default:
printf("What a beautiful %dth pair of legs!\n",i);
} } return(0); }
</pre>
Still not had enough? Read on!
Q) What did the male programmer centipede which was insanely particular about its code do, when it saw a female centipede it liked?
A) It wrote the following program:
<pre>
int main(){
int i=0;
for(i=1;i<101;i++){
switch(i%10){
case 1:
if(i==11){
printf("What a beautiful %dth pair of legs!\n",i);
break;
}
printf("What a beautiful %dst pair of legs!\n",i);
break;
case 2:
if(i==12){
printf("What a beautiful %dth pair of legs!\n",i);
break;
}
printf("What a beautiful %dnd pair of legs!\n",i);
break;
case 3:
if(i==13){
printf("What a beautiful %dth pair of legs!\n",i);
break;
}
printf("What a beautiful %drd pair of legs!\n",i);
break;
default:
printf("What a beautiful %dth pair of legs!\n",i)
} } return(0); }
</pre>
Results of the survey:-
1) If you just read the first part of this post, smiled and jumped to the last part, you are not a programmer.
2) If you read the whole post, you are a bored programmer.
3) If you read the whole post and actually liked the last program the best, you are a bored programmer who is particular about his/her code.
4) If you read the whole post and actually liked the last program the best, but spotted that the printf statement in the default case in the last program is missing a semicolon, you are a bored programmer who is insanely particular about his/her code!
Yaaaay!