ProgrammingHardGATE CS · Campus placements
unsigned int n = 3u; int k = -1; if (k > n) printf("yes"); else printf("no"); What is printed?
- A. prints yes
- B. prints no
- C. compile error
- D. undefined behaviour
Correct answer: A. prints yes
k is converted to unsigned for the comparison, giving UINT_MAX, which is greater than 3. The condition is true and the program prints yes.
More C Programming questions
- Which type reliably holds the sum 1 + 2 + ... + 100000 = 5000050000?
- What is (uint32t)~0u >> 28?
- int g[2][3] = {1, 2, 3, 4}; What is g[1][1] + g[0][2]?
- uint8t a = 200; a = a + a; What is a?
- Which statement about pointer relations in C is well defined?
- How many subsets of {0, 1, 2, 3, 4, 5} contain exactly three elements?