ProgrammingHardProduct company OA
What is printed?
What is printed?
printf("%d %d", !!"", !*"");- A. 0 0
- B. 1 0
- C. 0 1
- D. 1 1
Correct answer: D. 1 1
A string literal used as a value is a non-null pointer, so even the empty string "" is true and !!"" is 1. *"" is its first character, the '\0', so !*"" is also 1. Testing a string for emptiness must look at its first character.
More C Programming questions
- 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…
- What is printed? c printf("%d %d", strncmp("abc", "abd", 2) == 0, strncmp("ab", "ab0x", 5) == 0);