Re: without loop printing 1 to n



2006-12-22 <1166784884.365179.239100@xxxxxxxxxxxxxxxxxxxxxxxxxxx>,
jd wrote:

jd wrote:
jd wrote:
jd wrote:
Yahooooooooo wrote:
no gotos
no loops
how is it possbile.....
Asked in interview ...

Regards
MA#

recusion?

void foo(int a, b) {
if(a=b) then return
else {
printf("%d\n", a);
foo(a+1, b);
}
}

Whoops. Too hasty, == for equality, include stdio.h etc..

Bah! It gets worse! No 'then' obviously. Guess who has to program in
Delphi at the moment?

AAARRRGHH! And it only prints up to N-1 too. Should have been a>b.

I promise I'll never post again to clc.

You missed a semicolon </piling on>
.



Relevant Pages