ProgrammingHardGATE CS · Campus placements
A stair can be climbed by 1, 2 or 3 steps. How many ways are there to climb 4 stairs?
- A. 6
- B. 8
- C. 7
- D. 4
Correct answer: C. 7
Let W(n) = W(n-1) + W(n-2) + W(n-3) with W(0) = 1. Then W(1) = 1, W(2) = 2, W(3) = 4 and W(4) = 7.
More C Programming questions
- #define N 3 and int a[N 2 + 1]; What is sizeof a / sizeof a[0]?
- int x = 5, y = 3; What does printf("%d", x & y | 4 ^ 1) print?
- unsigned int n = 3u; int k = -1; if (k > n) printf("yes"); else printf("no"); What is printed?
- 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]?