ProgrammingModerateTCS NQT · Infosys
c is a char holding '5'. What is printf("%d", (c - '0') * 2)?
- A. 5
- B. 53
- C. 106
- D. 10
Correct answer: D. 10
c - '0' is 5 because the digit characters are contiguous in every conforming character set, and 5 * 2 = 10. Subtracting '0' first is the standard way to read a digit.
More C Programming questions
- How many 1 bits does 0b10101 have?
- A table of size 7 uses h(k) = k % 7 with linear probing. Keys 14, 21, 7 and 0 are inserted in that order. In which slot does key 0 land?
- Linear probing with a tombstone-free delete: keys 0 and 7 both hash to slot 0 in a table of size 7. 0 is stored at slot 0 and 7 at slot 1…
- Chaining with head insertion: keys 10, 3 and 17 all hash to bucket 3 in a table of size 7. Which key is first in the chain after the three…
- With linear probing at load factor 0.5, the expected number of probes for an unsuccessful search, under uniform hashing, is what?
- With linear probing at load factor 0.75, the expected number of probes for an unsuccessful search, under uniform hashing, is what?