ProgrammingHardTCS NQT · Infosys
What is printed?
What is printed?
printf("%d %d", '\0', '0');- A. 0 0
- B. 48 0
- C. 0 48
- D. 48 48
Correct answer: C. 0 48
'\0' is the null character, value 0, which ends every C string. '0' is the digit character, code 48 in ASCII. Confusing the two is a classic source of string bugs.
More C Programming questions
- What is printed? c printf("%d %d", !!"", !"");
- How many subsets does this code count? c int a[] = {2, 3, 5, 7, 8}, c = 0; for (int m = 0; m < 32; m++) { int s = 0; for (int i = 0; i <…
- What is the type of the result of subtracting two int pointers, p - q?
- What is printed? c char s[] = "xya", p = s; char a = p++; char b = ++p; char c = ++p; printf("%c%c%c %s", a, b, c, s);
- What is printed? c int hs(unsigned n) { return n ? (n & 0xF) + hs(n >> 4) : 0; } int main(void) { printf("%d", hs(0xBEEF)); }
- How many swaps does this bubble sort make? c int a[] = {3, 1, 4, 1, 5}, sw = 0; for (int i = 0; i < 5; i++) for (int j = 0; j < 4 - i…