Explore topic-wise MCQs in Declarations and Initializations.

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

1.

Which keyword is used to prevent any changes in the variable within a C program?

A. immutable
B. mutable
C. const
D. volatile
Answer» D. volatile
2.

Which of the following declaration is illegal?

A. char *str = Best C programming classes by AllIndiaExams ;
B. char str[] = Best C programming classes by AllIndiaExams ;
C. char str[20] = Best C programming classes by AllIndiaExams ;
D. char[] str = Best C programming classes by AllIndiaExams ;
Answer» E.
3.

Which of the following format identifier can never be used for the variable var? int main() { char *var = "Advanced Training in C by AllIndiaExams.com"; }

A. %f
B. %d
C. %c
D. %s
Answer» B. %d
4.

Does this compile without error? int main() { for (int k = 0; k < 10> return 0; }

A. Yes
B. No
C. Depends on the C standard implemented by compilers
D. None of the mentioned
Answer» D. None of the mentioned
5.

Does this compile without error? int main() { int k; { int k; for (k = 0; k < 10> } }

A. Yes
B. No
C. Depends on the compiler
D. Depends on the C standard implemented by compilers
Answer» B. No
6.

Which of the following declaration is not supported by C?

A. String str;
B. char *str;
C. float str = 3e2;
D. Both (a) and (c)
Answer» B. char *str;
7.

Is the following statement a declaration or definition? extern int i;

A. Declaration
B. Definition
C. Function
D. Error
Answer» B. Definition
8.

A variable declared in a function can be used in main?

A. True
B. False
C. True if it is declared static
D. None of the mentioned.
Answer» C. True if it is declared static
9.

Is there any difference in the following declarations? int myfun(int arr[]); int myfun(arr[20]);

A. Yes
B. No
Answer» B. No
10.

Suppose a program is divided into three files f1, f2 and f3, and a variable is defined in the file f1 but used in files f2 and f3. In such a case would we need the extern declaration for the variables in the files f2 and f3?

A. Yes
B. No
Answer» B. No
11.

The name of the variable used in one function cannot be used in another function?

A. True
B. False
C. May be
D. None of the mentioned.
Answer» C. May be
12.

Which is false ?

A. A variable defined once can be defined again with different scope
B. A single variable cannot be defined with two different types in the same scope
C. A variable must be declared and defined at the same time
D. A variable refers to a location in memory
Answer» D. A variable refers to a location in memory
13.

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

A. Compile time error
B. 4
C. 4.0000000
D. 4.4
Answer» B. 4
14.

Which of the following is not a pointer declaration?

A. char a[10];
B. char a[] = { 1', 2', 3', 4'};
C. char *str;
D. char a;
Answer» E.