ProgrammingModerateTCS NQT · Infosys
What is printed?
What is printed?
#include <stdio.h>
int main(void) {
char c = 'a';
printf("%d %d", c + 1 == 'b', '9' - '0');
}- A. 0 9
- B. 1 0
- C. 0 0
- D. 1 9
Correct answer: D. 1 9
c + 1 is the int value of 'b', so the comparison is true, giving 1. '9' - '0' is the digit value 9.
More C Programming questions
- What is printed? c #include <stdio.h> unsigned fibcalls = 0; int fib(int n) { fibcalls++; if (n < 2) return n; return fib(n - 1) + fib(n…
- What is printed for the sorted array below? c #include <stdio.h> int main(void) { int a[] = {1, 3, 3, 3, 5, 8}; int n = 6, lo = 0, hi = n…
- What is printed? c #include <stdio.h> int find(const char hay, const char nd) { for (const char p = hay; p; p++) { const char a = p, b =…
- What is printed? Assume int is 32 bits. c #include <stdio.h> int main(void) { unsigned a = 10; int b = -3; printf("%u", a % b); }
- What is printed? c #include <stdio.h> int main(void) { unsigned x = 40; int c = 0; while (!(x & 1u)) { x >>= 1; c++; } printf("%d", c); }
- What is printed? c #include <stdio.h> int main(void) { int a[] = {1, 2, 2, 3, 1, 4}; int c = 0; for (int i = 0; i < 5; i++) if (a[i] < a[i…