GATE CSE C Programming Practice Test – Function & Storage Class | Set 1

Questions 86-90 of 100

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

Question 86

NAT · Numerical Answer 2 mark

What is the output of the following C code?

C
#include <stdio.h>
int compute(int k) {
    static int s = 0;
    s += k;
    return s;
}
int main(void) {
    int sum = 0;
    for (int i = 1; i <= 3; i++) {
        sum += compute(i);
    }
    printf("%d", sum);
    return 0;
}
Answers for question 86

Question 87

NAT · Numerical Answer 1 mark

What is the output of the following C code?

C
#include <stdio.h>
void count_call(void) {
    static int c = 10;
    c += 5;
}
int main(void) {
    count_call();
    count_call();
    count_call();
    static int c = 50;
    printf("%d", c);
    return 0;
}
Answers for question 87

Question 88

NAT · Numerical Answer 1 mark

What is the output printed by main()?

C
#include <stdio.h>
int x = 10;
void modify(void) {
    int x = 20;
    x += 10;
}
int main(void) {
    modify();
    printf("%d", x);
    return 0;
}
Answers for question 88

Question 89

NAT · Numerical Answer 2 mark

What is the returned value of step(4)?

CODE
int step(int n) {
    static int a = 0;
    if (n <= 0) return a;
    a += n;
    return step(n - 1);
}
Answers for question 89

Question 90

NAT · Numerical Answer 1 mark

What is the output printed by the program?

C
#include <stdio.h>
int add(int a, int b) {
    return a + b;
}
int main(void) {
    int (*fptr)(int, int) = add;
    printf("%d", fptr(12, 18));
    return 0;
}
Answers for question 90
Scroll to Top