ProgrammingHardTCS NQT · Infosys
int x = 10; int *px = &x; *px += *px * 2; What is x?
- A. 20
- B. 30
- C. 40
- D. 12
Correct answer: B. 30
*px * 2 is 20, and adding that to *px gives 30. The pointer and the variable name refer to the same object.
More C Programming questions
- What is ~0u / 2 + 1 for a 32-bit unsigned int?
- What does (unsigned int)(-1) % 10 evaluate to on a platform with a 32-bit unsigned int?
- How many ways are there to write 5 as an unordered sum of 1s and 2s?
- void rev(char s) { char e = s + strlen(s) - 1; while (s < e) { char t = s; s++ = e; e-- = t; } } After rev("abcde") runs on a writable…
- Which algorithm finds the maximum subarray sum of an array of n = 10^6 ints in time within a typical 1 second contest limit?
- char s = "hello"; What is strlen(s + 2)?