9. Which statement will read a floating point value from the keyboard and store
ID: 3638000 • Letter: 9
Question
9. Which statement will read a floating point value from the keyboard and store it in the variable x?
A) printf(“float = %f”, x);
B) scanf(“&f”, %x);
C) scanf(“%d”, &x);
D) scanf(“%f”, &x);
10. Which statement will print the following variables correctly?int x; float y;
A) printf(“x = %d y = %f”, x , y);
B) printf(“x = %f y = %f”, x , y);
C) printf(“x = %d y = %lf”, x , y);
D) printf(“x = %d y = %d”, x, y);
11. What will be the result of the following printf statement?
float x = 1.0, y = 3.0;
printf(“%.4f”, x / y);
A) 1.0/3.0
B) .3
C) .3334
D) .3333
12. What will be the output of the following printf statement if the user enters 1234567890 at the keyboard when the scanf statement is executed?
int x, y, z;
scanf(“%2d%3d%5d”, &x, &y, &z);
printf(“%d %d %d”, x, y, z);
A) 1234567890
B) 12 34 567890
C) 12 345 67890
D) nothing, this is incorrect syntax
13. What will be the value of the floating point variable var1 after the following scanf statement if the user enters 123.45456.78 at the keyboard?
scanf(“%5f%7f”, &var1, &var2);
A) 12345
B) 123.4
C) 123.45
D) 45456
Explanation / Answer
Answers---- 9.(D) ---simple formatting of scanf() 10.(A)---simple formatting of printf() 11.(D)---- %.4f means print the result upto four decimal point, not round-up 12.(D)---- the result will be 12 345 2354 13.(D)--- the size of output is fixed as 5 so only 123.4 will be displayed.
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.