Basic and Advance C Question:
Download Job Interview Questions and Answers PDF
Why doesnt this code work?
Answer:
Why doesn't this code:
double d;
scanf("%f", &d);
work?
Unlike printf, scanf uses %lf for values of type double, and %f for float.%f tells scanf to expect a pointer-to-float, not the pointer-to-double you gave it. Either use %lf, or declare the receiving variable as a float.
double d;
scanf("%f", &d);
work?
Unlike printf, scanf uses %lf for values of type double, and %f for float.%f tells scanf to expect a pointer-to-float, not the pointer-to-double you gave it. Either use %lf, or declare the receiving variable as a float.
Download C Programming Interview Questions And Answers
PDF
Previous Question | Next Question |
Why doesnt that code work? | Why does the call char scanf work? |