Saturday, November 29, 2008

Predict the output of following programme

void myFunc (int x)
{
if (x > 0)
myFunc(--x);
printf("%d, ", x);
}
int main()
{
myFunc(5);
return 0;
}

Choice a: 1, 2, 3, 4, 5, 5,
Choice b: 4, 3, 2, 1, 0, 0,
Choice c: 5, 4, 3, 2, 1, 0,
Choice d: 0, 0, 1, 2, 3, 4,
Choice e: 0, 1, 2, 3, 4, 5,

1 comment:

rohit said...

answer is d, this is showing wrong answer e