ProgrammingHardTCS NQT · Accenture
What is printed?
What is printed?
#include <stdio.h>
int main(void) {
printf("%d", (int)(7 / 2 * 2.0));
}- A. 7
- B. 6
- C. 3
- D. 4
Correct answer: B. 6
7 / 2 is integer division giving 3, and 3 * 2.0 = 6.0, which the cast turns into 6.
More C Programming questions
- What is printed? c #include <stdio.h> int main(void) { int a = 2, b = 3; printf("%d", a ^ b == 1); }
- What is printed? c #include <stdio.h> int main(void) { printf("%d", !!(0x80) + !0 + !-1); }
- What is printed? c #include <stdio.h> int main(void) { printf("%d", 5 % -3); }
- What is printed? c #include <stdio.h> #include <string.h> int main(void) { printf("%d", strlen("hello") > 4 ? 1 : 0); }
- What is printed? Assume int is 4 bytes. c #include <stdio.h> int main(void) { printf("%d", (int)sizeof(char[3][4])); }
- What is printed? The hexadecimal literal is 0x1F and the comparison is with 31. c #include <stdio.h> int main(void) { printf("%d", 0x1F ==…