Explore topic-wise MCQs in Functions.

This section includes 84 Mcqs, each offering curated multiple-choice questions to sharpen your Functions knowledge and support exam preparation. Choose a topic below to get started.

1.

Is initialization mandatory for local static variables?

A. YES
B. NO
C. Depends on the compiler
D. Depends on the standard
Answer» C. Depends on the compiler
2.

What is the format identifier for static a = 20.5; ?

A. %s
B. %d
C. %f
D. Illegal declaration due to absence of data type
Answer» C. %f
3.

Functions have static qualifier for its declaration by default.

A. true
B. false
C. Depends on the compiler
D. Depends on the standard
Answer» C. Depends on the compiler
4.

What is the scope of a function?

A. Whole source file in which it is defined
B. From the point of declaration to the end of the file in which it is defined
C. Any source file in a program
D. From the point of declaration to the end of the file being compiled
Answer» E.
5.

What is the scope of an external variable?

A. Whole source file in which it is defined
B. From the point of declaration to the end of the file in which it is defined
C. Any source file in a program
D. From the point of declaration to the end of the file being compiled
Answer» E.
6.

The variable declaration with no storage class specified is by default:

A. auto
B. extern
C. static
D. register
Answer» B. extern
7.

Automatic variables are variables that are?

A.
B. B.
C. C.
D. D.
Answer» B. B.
8.

What linkage does automatic variables have?

A. Internal linkage
B. External linkage
C. No linkage
D. None of the mentioned
Answer» D. None of the mentioned
9.

What is the output of this C code? int main() { auto i = 10; const auto int *p = &i; printf("%d n", i); }

A. 10
B. Compile time error
C. Depends on the standard
D. Depends on the compiler
Answer» B. Compile time error
10.

Automatic variables are stored in:

A. stack
B. data segment
C. register
D. heap
Answer» B. data segment
11.

Default storage class if not any is specified for a local variable, is auto:

A. true
B. false
C. Depends on the standard
D. None of the mentioned
Answer» B. false
12.

Which of the following is a storage specifier?

A. enum
B. union
C. auto
D. volatile
Answer» D. volatile
13.

Automatic variables are allocated space in the form of a:

A. stack
B. queue
C. priority queue
D. random
Answer» B. queue
14.

The scope of an automatic variable is:

A. Within the block it appears
B. Within the blocks of the block it appears
C. Until the end of program
D. Both (a) and (b)
Answer» E.
15.

Which of the following cannot be static in C?

A. Variables
B. Functions
C. Structures
D. None of the mentioned
Answer» E.
16.

Which of the following storage class supports char data type?

A. register
B. static
C. auto
D. All of the mentioned
Answer» E.
17.

Automatic variables are initialized to?

A. Junk value
B. Nothing
C. Both (a) & (b)
Answer» C. Both (a) & (b)
18.

Automatic variables are allocated memory in?

A. heap
B. Data segment
C. Code segment
D. stack
Answer» E.
19.

What is the output of this C code? void main() { int x; } here x is?

A. automatic variable
B. static variable
C. global variable
D. register variable
Answer» B. static variable
20.

Automatic variables:

A. Exist only within that scope in which it is declared
B. Cease to exist after the block is exited
C. Only 1
D. Both (a) & (b)
Answer» E.
21.

Which of following is not accepted in C?

A.
B. B.
C. C.
D. D.
Answer» D. D.
22.

Assignment statements assigning value to local static variables are executed only once?

A. true
B. false
C. Depends on the code
D. None of the mentioned
Answer» C. Depends on the code
23.

Which of the following is true for static variable?

A. It can be called from another function.
B. It exists even after the function ends.
C. It can be modified in another function by sending it as a parameter.
D.
Answer» D.
24.

What is the output of this C code? void main() { m(); m(); } void m() { static int x = 5; x++; printf("%d", x); }

A. 6 7
B. 6 6
C.
D. D.
Answer» B. 6 6
25.

What is the output of this C code? int x = 5; void main() { int x = 3; m(); printf("%d", x); } void m() { x = 8; n(); } void n() { printf("%d", x); }

A. 8 3
B. 8 5
C. 3 8
D. 5 3
Answer» B. 8 5
26.

Array sizes are optional during array declaration by using ______ keyword.

A. auto
B. static
C. extern
D. register
Answer» D. register
27.

What is the output of this C code? void main() { int x = 3; { x = 4; printf("%d", x); } }

A. 4
B. 3
C. Undefined
Answer» B. 3
28.

Functions in C are ALWAYS:

A. Internal
B. External
C. Both Internal and External
D. External and Internal are not valid terms for functions
Answer» C. Both Internal and External
29.

What is the output of this C code? void main() { static int x = 3; x++; if (x <= 5) { printf("hi"); main(); } }

A. Run time error
B. hi
C. infinite hi
D. hi hi
Answer» E.
30.

What is the output of this C code? void main() { m(); } void m() { printf("hi"); m(); }

A. Compile time error
B. hi
C. Infinite hi
D. Nothing
Answer» D. Nothing
31.

What is the output of this C code? static int x; void main() { int x; printf("x is %d", x); }

A. Junk value
B. Run time error
C. Nothing
Answer» C. Nothing
32.

Global variables are:

A. Internal
B. External
C. Both (a) and (b)
D. None of the mentioned.
Answer» C. Both (a) and (b)
33.

Which of the following are an external variable? int func (int a) { int b; return b; } int main() { int c; func (c); } int d;

A. a
B. b
C. c
D. d
Answer» E.
34.

What is the output of this C code? int x = 5; void main() { int x = 3; printf("%d", x); { int x = 4; } printf("%d", x); }

A. 3 3
B. 3 4
C. 3 5
D. Run time error
Answer» B. 3 4
35.

What is the output of this C code? int x = 5; void main() { int x = 3; printf("%d", x); { x = 4; } printf("%d", x); }

A. Run time error
B. 3 3
C. 3 5
D. 3 4
Answer» E.
36.

What is the output of this C code? int x; void main() { printf("%d", x); }

A. Junk value
B. Run time error
C. Undefined
Answer» A. Junk value
37.

What is the output of code given below? enum m{JAN, FEB, MAR}; enum m foo(); int main() { enum m i = foo(); printf("%d n", i); } int foo() { return JAN; }

A. Compile time error
B. Depends on the compiler
C. Depends on the standard
Answer» B. Depends on the compiler
38.

What is the output of this C code? void main() { m(); printf("%d", x); } int x; void m() { x = 4; }

A. 4
B. Compile time error
C. Undefined
Answer» C. Undefined
39.

What will be the output? int main() { printf("%d", d++); } int d = 10;

A. 9
B. 10
C. 11
D. Compile time error
Answer» E.
40.

What will be the output? double var = 8; int main() { int var = 5; printf("%d", var); }

A. 5
B. 8
C. Compile time error due to wrong format identifier for double
D. Compile time error due to redeclaration of variable with same name
Answer» B. 8
41.

What is the output of this C code? void main() { static int x; printf("x is %d", x); }

A. 1
B. Junk value
C. Run time error
Answer» A. 1
42.

What is the output of this C code? void main() { m(); m(); } void m() { static int x = 5; x++; printf("%d", x); }

A. 6 7
B. 6 6
C. 5 5
D. 5 6
Answer» B. 6 6
43.

What is the output of this C code? static int x = 5; void main() { x = 9; { int x = 4; } printf("%d", x); }

A. 9
B. 4
C. 5
Answer» B. 4
44.

What is the output of this C code? int *i; int main() { if (i == NULL) printf("true n"); return 0; }

A. true
B. true only if NULL value is 0
C. Compile time error
D. Nothing
Answer» B. true only if NULL value is 0
45.

Property of external variable to be accessed by any source file is called by C90 standard as:

A.
B. B.
C. C.
D. D.
Answer» B. B.
46.

Can variable i be accessed by functions in another source file? int i; int main() { printf("%d n", i); }

A. false
B. Only if static keyword is used
C. Depends on the type of the variable
Answer» A. false
47.

Which part of the program address space is p stored in the code given below? int *p; int main() { int i = 0; p = &i; return 0; }

A. Code/text segment
B. Data segment
C. Bss segment
D. Stack
Answer» D. Stack
48.

Which part of the program address space is p stored in the code given below? int *p = NULL; int main() { int i = 0; p = &i; return 0; }

A. Code/text segment
B. Data segment
C. Bss segment
D. Stack
Answer» C. Bss segment
49.

What is the output of this C code? double i; int main() { printf("%g n",i); return 0; }

A. 0.000000
B. Garbage value
C. Depends on the compiler
Answer» C. Depends on the compiler
50.

functions can return enumeration constants in c?

A. true
B. false
C. depends on the compiler
D. depends on the standard
Answer» B. false