What will be the output of the program?
#include <stdio.h>
int main()
{
typedef int LONG;
LONG a=4;
LONG b=68;
float c=0;
c=b;
b+=a;
printf("%d,", b);
printf("%f\n", c);
return 0;
}
Answer: A
Correct answer: 72, 68.000000
Take the two statements in order. c = b; copies 68 into the float before any addition, so c holds 68. Then b += a; makes b equal to 72. The output is therefore 72 from %d and 68.000000 from %f, which prints six decimal places by default. LONG is simply an alias for int and changes nothing.
Please log in or register to report this question.