C++ MCQ Questions and Answers
C++ MCQ questions and answers are vital for students preparing for software development and IT placement exams like TCS, Infosys, and Tech Mahindra. These questions test your understanding of core concepts such as classes, objects, inheritance, polymorphism, and templates. Practicing C++ programming MCQs with detailed explanations helps strengthen coding logic and syntax understanding. This topic is ideal for candidates aiming to improve their performance in programming interview questions with answers and campus recruitment tests.
C++ MCQ
Showing 10 of
93 questions
61. The size of following variable is not 4 bytes in 32 bit systems
- int
- long int
- short int
- float
62. Identify the correct statement regarding scope of variables
- Global variables are declared in a separate file and accessible from any program.
- Local variables are declared inside a function and accessible within the function only.
- Global variables are declared inside a function and accessible from anywhere in program.
- Local variables are declared in the main body of the program and accessible only from functions.
63. Find out the error in following block of code. If (x = 100) Cout << "x is 100";
- 100 should be enclosed in quotations
- There is no semicolon at the end of first line
- Equals to operator mistake
- Variable x should not be inside quotation
64. Looping in a program means
- Jumping to the specified branch of program
- Repeat the specified lines of code
- Both of above
- None of above
65. The difference between while structure and do structure for looping is
- In while statement the condition is tested at the end of first iteration
- In do structure the condition is tested at the beginning of first iteration
- The do structure decides whether to start the loop code or not whereas while statement decides whether to repeat the code or not
- In while structure condition is tested before executing statements inside loop whereas in do structure condition is tested before repeating the statements inside loop
67. Which of the following is not a jump statement in C++?
- break
- goto
- exit
- switch
69. The continue statement
- resumes the program if it is hanged
- resumes the program if it was break was applied
- skips the rest of the loop in current iteration
- all of above
70. Consider the following two pieces of codes and choose the best answer Code 1: switch (x) { case 1: cout <<"x is 1"; break; case 2: cout <<"x is 2"; break; default: cout <<"value of x unknown"; } Code 2 If (x==1){ Cout <<"x is 1"; } Else if (x==2){ Cout << "x is 2"; } Else{ Cout <<"value of x unknown"; }
- Both of the above code fragments have the same behaviour
- Both of the above code fragments produce different effects
- The first code produces more results than second
- The second code produces more results than first.