ProgrammingHardTCS NQT · Infosys
What is printed?
What is printed?
#include <stdio.h>
int main(void) {
printf("%d", (1, 2));
}- A. 1
- B. 3
- C. 0
- D. 2
Correct answer: D. 2
The parentheses form a comma expression, whose value is its right operand, 2. The comma here is an operator, not an argument separator.
More C Programming questions
- What is printed? c #include <stdio.h> int main(void) { char c = 'a'; printf("%d", c++ == 'a' && c == 'b'); }
- What is printed? c #include <stdio.h> int main(void) { printf("%s", "ab" "cd"); }
- What is printed? Assume unsigned int is 32 bits. c #include <stdio.h> int main(void) { printf("%u", 1 ? -1 : 0u); }
- How many partitions of 6 into distinct parts are there? The recursion below counts them. What is printed? c #include <stdio.h> int dp(int…
- How many ways are there to tile a 1 by 4 strip with 1 by 1 and 1 by 2 tiles? The recursion computes it. What is printed? c #include…
- What is printed? The program computes the parity of the set bits of 0b1101. c #include <stdio.h> int parity(unsigned x) { return x == 0 ?…