C programing trick!!

What is wrong ??
#include
#include

void main()
{
    printf("%10.0f",-3456);
    getch();
}


There might be some tricks on C programming section in an interview test. Have you ever experienced such kind of trick. If not, above is one of a typical examples which might be on your interview test.

Try to figure out what is going on with above short code !!!

At the first glance, you may ask yourself what is wrong with it. It is just a simple code, nothing wrong with it. But, when you actually run this kind of code. the printing result is not as your expected. It's gonna be 0.

What is the problem here? ---> Try to figure it out by yourself ;)

How to fix that code to run in a proper way ?
--->  it is so easy, isn't it. Just need to put 3456.0 instead of 3456

No comments:

Post a Comment

Related Posts Plugin for WordPress, Blogger...