1.
Identify the correct statement
Correct Answer
A. Programmer can use comments to include short explanations within the source code itself.
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.
2.
The directives for the preprocessors begin with
Correct Answer
C. Number Sign (#)
Explanation
The correct answer is the number sign (#). Directives for preprocessors typically begin with the number sign symbol (#).
3.
The file iostream includes
Correct Answer
A. The declarations of the basic standard input-output library.
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.
4.
There is a unique function in C++ program by where all C++ programs start their execution
Correct Answer
C. Main()
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.
5.
Every function in C++ are followed by
Correct Answer
B. Parenthesis
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++.
6.
Which of the following is false?
Correct Answer
D. None of above
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.
7.
Every statement in C++ program should end with
Correct Answer
C. A Semicolon (;)
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.
8.
Which of the following statement is true about preprocessor directives?
Correct Answer
D. They end with a semicolon
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.
9.
A block comment can be written by
Correct Answer
B. Starting with /* and ending with */
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.
10.
When writing comments you can
Correct Answer
B. Use code and // comments on the same line
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.