0 votes 0 votes what is the output for the below program ? main() { float x=1/2; float y=1/2.0; printf("%f, %f", x,y); } A) 0.500000, 0.500000 B) 0.500000, 0.000000 C) 0.000000, 0.000000 D) 0.000000, 0.500000 Programming in C programming-in-c output + – Karthik Akula asked Oct 29, 2016 edited Oct 29, 2016 by Karthik Akula Karthik Akula 4.1k views answer comment Share Follow See 1 comment See all 1 1 comment reply Digvijaysingh Gautam commented Oct 29, 2016 reply Follow Share I think for this type of questions u should first try to execute on ur machine and search on the internet why such type of error occurs. If u still dont understand then ask here. 2 votes 2 votes Please log in or register to add a comment.
Best answer 7 votes 7 votes #include <stdio.h> int main() { float x=1/2; // integer airthematic x = 0 float y=1/2.0; // y = 0.50 printf("%f, %f", x, y); // output = 0,0.50 return 0; } mcjoshi answered Oct 29, 2016 selected Oct 29, 2016 by Arjun mcjoshi comment Share Follow See 1 comment See all 1 1 comment reply Mayankprakash commented Aug 30, 2018 reply Follow Share @mcjoshi I didn't understand concept behind it. Can you please elaborate.It will be so helpful. Thanks 0 votes 0 votes Please log in or register to add a comment.