Ex - 2: What is the output?
void main()
{
while(1){
if(printf("%d",printf("%d")))
break;
else
continue;
}
}
Ans:
Garbage values
Explanation:
The inner printf executes first to print some garbage value. The printf returns no of characters printed and this value also cannot be predicted. Still the outer printf prints something and so returns a non-zero value. So it encounters the break statement and comes out of the while statement.
|