GATE Computer ScienceHardGATE CSE · ISRO
int c = 0; for (int i = 1; i < 100; i *= 2) for (int j = 0; j < i; j++) c++; What is the final value of c?
- A. 126
- B. 128
- C. 100
- D. 127
Correct answer: D. 127
i takes 1, 2, 4, 8, 16, 32, 64, and the inner loop runs i times: sum = 127.
Practise more Programming and Data Structures (GATE) questionsProgramming and Data Structures (GATE): notes and key points
More Programming and Data Structures (GATE) questions
- void f(int a[], int n) { a[0] = n; n = a[1]; a = a + 1; a[0] = 99; } int main() { int x[3] = {1, 2, 3}; int m = 5; f(x, m); printf("%d %d…
- How many structurally distinct binary search trees on 6 keys have height exactly 3, where height is the number of edges on the longest…
- In how many different ways can the keys 1, 2, …, 7 be arranged in the array of a binary max-heap (every parent greater than its children)?
- A binary max-heap is built from 15 elements by Floyd's bottom-up method (sift-down from the last internal node to the root). Each level of…
- int A(int m, int n) { if (m == 0) return n + 1; if (n == 0) return A(m - 1, 1); return A(m - 1, A(m, n - 1)); } How many times is A…
- Thirteen people numbered 1 to 13 stand in a circle (circular linked list). Starting the count at person 1 (who counts as 1), every 4th…