ProgrammingHardTCS NQT · Wipro
What is printed?
What is printed?
#include <stdio.h>
int main(void) {
char c = 'a';
printf("%d", c++ == 'a' && c == 'b');
}- A. 1
- B. 0
- C. 2
- D. 3
Correct answer: A. 1
c++ yields 'a' in the first test and then c becomes 'b', so both operands of && are true. The second test sees the incremented value.
More C Programming questions
- 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 ?…
- What is the position of the lowest set bit of 0x0300 (counting bit 0 as position 0)? Compute with this program. c #include <stdio.h> int…