LearnFrenzy
Sign in Take a free test

Basic Syntax and Data Types · Exercise 1 of 4

Basic Syntax and Data Types Basic Syntax MCQ

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

Twenty multiple-choice questions on C++ program structure, namespaces, data types, initialization, auto, const and constexpr. Pick an option to check your answer instantly.

Question 11 Medium

What is the type of the character literal 'A' in C++?

A int, as in C
B char
C string
D wchar_t
Question page & discussion
Question 12 Easy

What is static_cast<double>(a) used for?

A To make a variable static
B An explicit, compiler-checked conversion of a to double
C To allocate memory
D To convert a pointer to an integer
Question page & discussion
Question 13 Easy

Which statement about std::cerr is true?

A It reads errors from the keyboard
B It writes to the standard error stream and is unbuffered, so messages appear immediately
C It is the same as std::cout
D It throws an exception
Question page & discussion
Question 14 Easy

In which order are these stages performed when building a C++ program?

A Compilation → preprocessing → linking → assembly
B Preprocessing → compilation → assembly → linking
C Linking → compilation → preprocessing → assembly
D Preprocessing → linking → compilation → assembly
Question page & discussion
Question 15 Easy

Which escape sequence inserts a horizontal tab in a string?

A \n
B \t
C \b
D \a
Question page & discussion
Question 16 Easy

Which of the following is not a fundamental (built-in) type?

A bool
B double
C std::string
D char
Question page & discussion
Question 17 Easy

Inside a function, what does int x{}; contain?

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

What does using Score = int; do?

A Creates a new type unrelated to int
B Declares Score as another name (alias) for int
C Creates a variable named Score
D Imports a namespace
Question page & discussion
Question 19 Easy

What value does bool b = 5; store?

A 5
B true
C false
D Compilation error
Question page & discussion
Question 20 Medium

What does the C++ standard say about int x = INT_MAX; x = x + 1;?

A x becomes INT_MIN
B x becomes 0
C The behaviour is undefined
D An exception is thrown
Question page & discussion
Up next · Exercise 2Predict the Output20 questions

Ready to test your Programming?

Timed online tests with instant scores and explanations.

Search LearnFrenzy

Esc

Quick links