Oct 27, 2010

Find the output.

Try this..
main()
{
printf("\nab");
printf("\bsi");
printf("\rha");
}
What is the output of above program??

Answer:
hai

Explanation:
The first printf statement prints 'ab'
The second printf statement prints 'asi'(bcoz \b backspace cmd prints next to 'a' and overwrites 'b')
The third printf statement prints 'hai' (bcoz \r return cmd overwrites on 'asi')

No comments:

Post a Comment