ProgrammingHardGATE CS · TCS NQT
What is printed? Assume int is 4 bytes.
What is printed? Assume int is 4 bytes.
#include <stdio.h>
int main(void) {
printf("%d %zu", 1 ? 'A' : 0, sizeof(1 ? 'A' : 0));
}- A. 65 1
- B. A 4
- C. 65 4
- D. 65 0
Correct answer: C. 65 4
The conditional operator's result has type int here, because 'A' is promoted to int in the expression, so the value is 65 and its size is 4. Printing the character would give A.
More C Programming questions
- What is printed? Assume unsigned long long is 64 bits. c #include <stdio.h> int main(void) { unsigned long long x = (1ULL << 40) - 1; int…
- What is printed? c #include <stdio.h> int main(void) { int a[] = {1, 2, 3}; int p = a; p += 2; printf("%d", p - (p - 2)); }
- What is printed? Assume unsigned short is 16 bits and int is 32 bits. c #include <stdio.h> int main(void) { printf("%d", (unsigned…
- How many binary strings of length 4 contain no two consecutive 1s? Compute with this recursive program. c #include <stdio.h> int f(int n)…
- What is printed? c #include <stdio.h> int main(void) { unsigned char a = 100, b = 200; unsigned char s = (unsigned char)(a + b) / 2…
- How many times does the loop body run? c #include <stdio.h> int main(void) { int c = 0; for (int i = 0, j = 0; i < 4 && j < 4; i++, j +=…