ProgrammingModerateTCS NQT · Infosys
What is printed?
What is printed?
#include <stdio.h>
int main(void) {
printf("%d", '\n' == 10 && '\0' == 0);
}- A. 0
- B. 2
- C. 1
- D. 3
Correct answer: C. 1
'\n' is the character with value 10 and '\0' is 0, so both comparisons hold and the result is 1.
More C Programming questions
- What is printed? Assume uint8t is 8 bits. c #include <stdint.h> #include <stdio.h> int main(void) { uint8t x = 0x1F; uint8t r =…
- What is printed? c #include <stdio.h> #include <stdlib.h> int ds(int n) { int s = 0; while (n) { s += n % 10; n /= 10; } return s; } int…
- How many ordered ways are there to write 6 as a sum of parts 1, 2 and 3? Compute with this program. c #include <stdio.h> int f(int n) { if…
- What is printed? c #include <stdio.h> int main(void) { unsigned x = 7; int i = 0; while (x & 1u) { x >>= 1; i++; } printf("%d", i); }
- What is printed? Assume unsigned short is 16 bits. c #include <stdio.h> int main(void) { unsigned short a = 255, b = 255; unsigned c = a…
- What is printed? c #include <stdio.h> #include <string.h> int main(void) { char w[] = {"ab", "cde"}; char p = w; printf("%d"…