GATE CSE C Programming Practice Test – Data Types & Operators | Set 1

Questions 51-55 of 100

Your score 0/100 0 answered
Correct 0 Incorrect 0 Unanswered 100 Accuracy 0%

Question 51

MCQ · Single Correct 1 mark

What output is generated by calling 'print_rev(4)'?

C
#include <stdio.h>
void print_rev(int n) {
    if (n == 0) return;
    printf("%d ", n);
    print_rev(n - 1);
}
Answers for question 51

Question 52

MCQ · Single Correct 1 mark

What does the following recursive function return for 'gcd(48, 18)'?

JAVASCRIPT
int gcd(int a, int b) {
    if (b == 0) return a;
    return gcd(b, a % b);
}
Answers for question 52

Question 53

MCQ · Single Correct 1 mark

What is the maximum number of activation records on the stack for 'fib(4)' with naive recursion?

Answers for question 53

Question 54

MCQ · Single Correct 1 mark

What will be printed by 'main()' when executing this code?

C
#include <stdio.h>
int fun(int n) {
    if (n == 1) return 1;
    if (n % 2 == 0) return fun(n / 2);
    else return fun(3 * n + 1);
}
int main(void) {
    printf("%d", fun(6));
    return 0;
}
Answers for question 54

Question 55

MCQ · Single Correct 1 mark

What is the output of the following C loop?

C
#include <stdio.h>
int main(void) {
    int i = 0;
    for (; i < 5; i++) {
        if (i == 3) break;
    }
    printf("%d", i);
    return 0;
}
Answers for question 55
Scroll to Top