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

Questions 6-10 of 100

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

Question 6

MCQ · Single Correct 1 mark

What will be the output of the following program?

C
#include <stdio.h>
void increment(void) {
    static int count = 5;
    count++;
    printf("%d ", count);
}
int main(void) {
    increment();
    increment();
    increment();
    return 0;
}
Answers for question 6

Question 7

MCQ · Single Correct 1 mark

What is the compilation result of initializing a static local variable with a non-constant automatic variable, such as 'int val = 10; static int s_val = val;'?

Answers for question 7

Question 8

MCQ · Single Correct 1 mark

What are the default initial values of uninitialized automatic (auto) and global static variables in C respectively?

Answers for question 8

Question 9

MCQ · Single Correct 1 mark

Why is returning the pointer to a non-static local variable from a C function unsafe?

Answers for question 9

Question 10

MCQ · Single Correct 1 mark

What is the output of the following C program?

C
#include <stdio.h>
void fnA(void) {
    static int x = 10;
    x++;
    printf("%d ", x);
}
void fnB(void) {
    static int x = 50;
    x++;
    printf("%d ", x);
}
int main(void) {
    fnA(); fnB(); fnA(); fnB();
    return 0;
}
Answers for question 10
Scroll to Top