0 votes 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 asked Jul 9, 2018 • edited Jul 9, 2018 by srestha Shijith M 872 views answer comment Share Follow See all 0 reply Please log in or register to add a comment.
0 votes 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 See all 10 10 Comments reply Show 7 previous comments Anil Ji commented Jul 9, 2018 reply Follow Share https://ideone.com/3R6t5V sir this is the output 0 votes 0 votes Arjun commented Jul 9, 2018 reply Follow Share 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 votes 2 votes Anil Ji commented Jul 9, 2018 reply Follow Share thank you sir 0 votes 0 votes Please log in or register to add a comment.