ProgrammingModerateTCS NQT · Infosys
What is printed? Assume int is 4 bytes.
What is printed? Assume int is 4 bytes.
#include <stdio.h>
int main(void) {
printf("%zu", sizeof('a'));
}- A. 1
- B. 8
- C. 2
- D. 4
Correct answer: D. 4
Character constants in C have type int, so sizeof 'a' is the size of int, which is 4 here. In C++ the same expression gives 1.
More C Programming questions
- What is printed? c #include <stdio.h> int main(void) { printf("%d", ~5 & 0xF); }
- What is printed? c #include <stdio.h> int main(void) { unsigned char c = 254; int n = 0; while (++c) n++; printf("%d", n); }
- How many iterations does this binary search make to find 13 in the sorted array 0 to 15? Compute with the program. c #include <stdio.h>…
- n <= 10^5 values, each up to 10^9, must be summed. Which declaration is correct for the total?
- To test whether n = 10^12 is prime by trial division up to sqrt(n), which loop is correct?
- A middle index of a range [lo, hi] is needed for hi near INTMAX. Which expression is safe?