ProgrammingHardTCS NQT · Infosys
for (int i = 0, j = 10; i < j; i += 3, j -= 3) count++; How many times does the body run?
- A. 2
- B. 3
- C. 4
- D. 1
Correct answer: A. 2
The pairs are (0,10), (3,7) and then (6,4), which fails i < j. The body runs twice.
More C Programming questions
- int n = 5; int r = n++ 2; What are the final values of r and n?
- Adding two non-negative ints a and b without +, a loop repeats a = a ^ b and b = (old a & old b) << 1 until b is 0. Starting with a = 5…
- uint8t sum = (uint8t)(200 + 100); if (sum < 50) printf("yes"); else printf("no"); What is printed?
- char msg[] = "abc"; printf("%c", msg[msg[0] - 'a' + 1]); What is printed?
- for (int i = 0; i < 10; i++) for (int j = 1; j < 10; j = 2) count++; How many times does count increase?
- What does printf("%d %d", 17 / 5, 17 % 5) print?