CPP Syntax MCQ
Cpp MCQ(1) In C++ statement termination symbol is:
A) .
B) ,
C) ;
D) ?
Explanation
Every C++ I/O statement must ends with semicolon.
(2) In C++ programs format string is always written within:
A) Single Quotes
B) Double Quotes
C) Angle Brackets
D) Parentheses
Explanation
Format string is used with cout object. It may include 1. Text 2. Format Specifier 3. Escape Sequence. It is always written within double quotes.
(3) Which of the following operator is used with cout object ?
A) !!
B) #
C) >>
D) <<
Explanation
<< (insertion operator) is used with cout object for sending output to standard output device.
(4) A well defined function must have
A) Return Type
B) Function Name
C) Parameter
D) All of these
Explanation
A well defined function works such like a machine. That takes some kind of input as parameter/argument, process this input in it's body and then generate/return output. This output may be displayed inside the function body or return to location from it called.
(5) How many parts of main() function in C++ program
A) One
B) Two
C) Three
D) Four
Explanation
There are three parts of C++ program. Which are 1. Return Type 2. Function Name 3. Parameter
(6) What is meant by 0 return from main() function in C++ program
A) Successful Completion
B) Unsuccessful Completion
C) Code Conversion
D) Exception
Explanation
Every main() function which has int return type must return some integer value from it's body. On successful completion programmer return 0.
(7) Preprocessor directives are always start with __________ symbol.
A) $
B) @
C) #
D) !
Explanation
Preprocessor directives are the library files or define directives. These are normally included at the top of C++ program, and always start with # sign.
(8) How many main functions does a C++ program may have?
A) One
B) Two
C) Three
D) Four
Explanation
Every C++ program only have a single main() function. Which means only one entry point for execution.
(9) The execution of actual program starts from:
A) return type
B) main function
C) header files
D) none of these
Explanation
Actual program is the set of instruction that are written by the programmer himself. These instructions are written in main function. So that actual execution starts from main() function.