LearnFrenzy
Sign in Take a free test

Declarations and Initializations · Exercise 1 of 4

Declarations and Initializations Declarations MCQ

  • 12 questions
  • Page 1 of 2
  • Answers explained
0Attempted
0Correct
0Wrong
Directions

Twelve multiple-choice questions on declaration vs definition, extern and prototypes, linkage, identifier rules, literal types, initializers, volatile and C23. Pick an option to check your answer instantly.

Question 1 Easy

Which line only declares a variable, without defining it?

A int count = 0;
B extern int count;
C static int count;
D int count; (inside a function)
Question page & discussion
Question 2 Medium

Is there any difference between extern int fun(); and int fun();?

A Yes, the first one is a definition
B No – function declarations have external linkage by default
C Yes, the second one is local to the file
D The first is invalid
Question page & discussion
Question 3 Easy

By default, a real number constant such as 2.5 is treated as a…

A float
B double
C long double
D int
Question page & discussion
Question 4 Medium

What kinds of linkage can an identifier have in C?

A Internal and external only
B External, internal and none
C Static and dynamic
D Local and global
Question page & discussion
Question 5 Easy

Which special symbol may appear in a variable name?

A - (hyphen)
B _ (underscore)
C $ (dollar)
D @ (at)
Question page & discussion
Question 6 Easy

When do we need to give a function's prototype?

A After the function is defined
B Before the function is called, when the definition comes later or is in another file
C Only for functions returning int
D Never in C99
Question page & discussion
Question 7 Easy

Which of the following is not a user-defined data type?

A struct book { char title[40]; };
B enum day { MON, TUE };
C union num { int i; float f; };
D long int
Question page & discussion
Question 8 Easy

Which expression gives the remainder after dividing 3.14 by 2.1?

A 3.14 % 2.1
B fmod(3.14, 2.1)
C mod(3.14, 2.1)
D rem(3.14, 2.1)
Question page & discussion
Question 9 Easy

Which call turns 1.66 into 2.0?

A floor(1.66)
B ceil(1.66)
C (int) 1.66
D trunc(1.66)
Question page & discussion
Question 10 Easy

After int a[5] = {1}; inside a function, what is a[3]?

A 1
B 0
C Garbage
D It does not compile
Question page & discussion

Ready to test your Programming?

Timed online tests with instant scores and explanations.

Search LearnFrenzy

Esc

Quick links