0 0 votes Consider a C Program situation like this, main() { float a=2.23564; printf("%d",a); } Then what will be the output?? please help me.. Programming in C programming-in-c + – Shijith M 1.6k views answer comment Share Follow Print 0 reply Please log in or register to add a comment.
0 0 votes As here a is declared as float and a=2.23564 %d specifier is used to print some integer value but here a is declared as float so some garbage value will be printed as output. Anil Ji answered Jul 9, 2018 Anil Ji comment Share Follow See all 10 Comments 10 10 Comments reply Show 7 previous comments Anil Ji commented Jul 9, 2018 reply Follow flag https://ideone.com/3R6t5V sir this is the output 0 0 replyShare Arjun commented Jul 9, 2018 reply Follow flag Undefined means compiler is free to output anything. Simply speaking, most compilers are just outputting whatever is in the Integer register when they see "%d" but the float value is passed in FLOAT registers. But a new compiler or new system may do differently - that is why this is undefined behaviour. Instead of wasting time on such undefined stuffs, focus on questions which are relevant for GATE or real programming. 2 2 replyShare Anil Ji commented Jul 9, 2018 reply Follow flag thank you sir 0 0 replyShare Please log in or register to add a comment.