Friday 22 March 2013

if(printf("%d",printf("%d")))


    void main()
{
    while(1){
         if(printf("%d",printf("%d")))
             break;
         else
             continue;
    }
}
Answer:
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.



Blog Author: Vijay Kumar

No comments:

Post a Comment