C++ MCQ – Basic Objective Questions – Set 2

Reviewed by Editorial Team
The ProProfs editorial team is comprised of experienced subject matter experts. They've collectively created over 10,000 quizzes and lessons, serving over 100 million users. Our team includes in-house content moderators and subject matter experts, as well as a global network of rigorously trained contributors. All adhere to our comprehensive editorial guidelines, ensuring the delivery of high-quality content.
Learn about Our Editorial Process
| By Allcompiler
A
Allcompiler
Community Contributor
Quizzes Created: 4 | Total Attempts: 23,557
| Attempts: 963 | Questions: 10
Please wait...
Question 1 / 10
0 %
0/100
Score 0/100
1. Every statement in C++ program should end with

Explanation

In C++ programming, every statement should end with a semicolon (;). This is because the semicolon serves as a statement terminator, indicating the end of a particular line of code. It is essential to include the semicolon to ensure that the compiler can correctly interpret and execute the program. Omitting the semicolon can result in a syntax error and cause the program to fail during compilation. Therefore, the correct answer is a semicolon.

Submit
Please wait...
About This Quiz
C++ MCQ  Basic Objective Questions  Set 2 - Quiz

Online MCQ Quiz on C++ Programming Language
This Quiz is for those users who want to test their command over the C++ Programming Language.

Personalize your quiz and earn a certificate with your name on it!
2. There is a unique function in C++ program by where all C++ programs start their execution

Explanation

In C++, the main() function is the unique function where all C++ programs start their execution. It serves as the entry point of the program, and any code written inside the main() function will be executed first. The main() function is required in every C++ program and is responsible for controlling the flow of the program by calling other functions and executing statements.

Submit
3. The directives for the preprocessors begin with

Explanation

The correct answer is the number sign (#). Directives for preprocessors typically begin with the number sign symbol (#).

Submit
4. A block comment can be written by

Explanation

A block comment can be written by starting with /* and ending with */. This is the correct way to write a block comment in many programming languages, including C, C++, and Java. The /* symbolizes the start of the comment block, and the */ symbolizes the end of the comment block. This allows multiple lines of code to be commented out at once, making it easier to add explanations or temporarily disable code.

Submit
5. When writing comments you can

Explanation

The correct answer is "Use code and // comments on the same line". This is because in most programming languages, including C++, Java, and Python, the double forward slash "//" is used to indicate a single-line comment. This allows you to add comments to your code without affecting its functionality. Using "//" comments on the same line as the code is a common practice and makes the code more readable and easier to understand for other developers.

Submit
6. The file iostream includes

Explanation

The file iostream includes the declarations of the basic standard input-output library. This means that it contains the necessary functions and objects for performing input and output operations in a C++ program. These include functions like cout and cin, which are used for outputting and inputting data respectively. Including the iostream file allows the program to use these input-output functions and objects.

Submit
7. Every function in C++ are followed by

Explanation

In C++, every function is followed by parentheses. These parentheses are used to enclose the parameters that are passed to the function. The parameters are the values or variables that the function needs in order to perform its task. The parentheses are essential in order to correctly call and execute a function in C++. The other options, such as parameters or curly braces, are not always present after every function in C++.

Submit
8. Which of the following is false?

Explanation

The statement "None of above" is false because all of the previous statements are true. Cout represents the standard output stream in C++, it is declared in the iostream standard file, and it is declared within the std namespace.

Submit
9. Which of the following statement is true about preprocessor directives?

Explanation

Preprocessor directives are lines of code that are read and processed by the preprocessor before the compilation of the program. They are not responsible for producing any code themselves, but rather modify the code before it is compiled. These directives must be written on their own line and they end with a semicolon. This is because the semicolon is used to terminate statements in most programming languages, and the preprocessor treats directives as statements that need to be terminated.

Submit
10. Identify the correct statement

Explanation

Programmers can use comments to include short explanations within the source code itself. This allows them to provide additional information or clarify certain sections of the code for themselves or other developers who may work on the code in the future. Comments are typically denoted by using two slash signs at the beginning of the line. They are not considered executable code and do not have any effect on the behavior of the program when it is run. Therefore, the correct statement is that programmers can use comments to include short explanations within the source code itself.

Submit
View My Results

Quiz Review Timeline (Updated): Mar 22, 2023 +

Our quizzes are rigorously reviewed, monitored and continuously updated by our expert board to maintain accuracy, relevance, and timeliness.

  • Current Version
  • Mar 22, 2023
    Quiz Edited by
    ProProfs Editorial Team
  • Sep 01, 2011
    Quiz Created by
    Allcompiler
Cancel
  • All
    All (10)
  • Unanswered
    Unanswered ()
  • Answered
    Answered ()
Every statement in C++ program should end with
There is a unique function in C++ program by where all C++ programs...
The directives for the preprocessors begin with
A block comment can be written by
When writing comments you can
The file iostream includes
Every function in C++ are followed by
Which of the following is false?
Which of the following statement is true about preprocessor...
Identify the correct statement
Alert!

Advertisement