C++ General Quiz 1

General quiz that can be taken as a self test to enhance your understanding for purposes of an interview or examination.

Last Reviewed and Updated on February 7, 2020
Posted by Parveen(Hoven),
Aptitude Trainer and Software Developer

Quiz Questions

Each question has four choices. More than one options can be correct. When you have finished the quiz, click the button at the end of the questions to view the result, and the solutions and answers.


Your Score
Correct Answers:
Wrong Answers:
Unattempted:

Q 1. Which compiler would you use to write a scaleable C/C++ project that targets the Windows OS ?
A. Microsoft Visual Basic
B. Microsoft Office 2011
C. Microsoft Visual C++
D. Turbo Compiler
  A - B - C - D
Soln. Ans: c
Evaluation:

Q 2. Which of these is the correct main for the entry-point function as per the C-Standard ?
A. void main (){}
B. int main (){}
C. int main (){return 0;}
D. int Main (){return 0;}
  A - B - C - D
Soln. Ans: c
Evaluation:

Q 3. With every data-type in C/C++ that requires memory allocation, you can associate
A. a value
B. an address or reference
C. Both (a) and (b)
D. None of the above
  A - B - C - D
Soln. Ans: c
Evaluation:

Q 4. How many times does the following loop execute ?
for (i = 0; i < 10; i++) 
{

}
A. 10 times
B. for ever
C. 9 times
D. 11 times
  A - B - C - D
Soln. Ans: a
Evaluation:

Q 5. Which is a good programming practice ?
A. Always make a provision for exit from a loop.
B. Use a lot many variables without worrying about memory allocation.
C. Type a complete program, howsoever long, and compile only after the typing has ended.
D. All of the above.
  A - B - C - D
Soln. Ans: a
Evaluation:

Q 6. Which is the correct input-output usage ?
A. scanf ("%u", i); printf("%u", &i);
B. scanf("%u", &i);printf(%u", i);
C. scanf("%u", &i);printf("%u",&i);
D. scanf("%u", i);printf("%u",i);
  A - B - C - D
Soln. Ans: b
Evaluation:

Q 7. How many times does the following loop execute ?
for (i = 0; i < 10; i--) 
{

}
A. 10 times
B. for ever
C. 9 times
D. 11 times
  A - B - C - D
Soln. Ans: b
Evaluation:

Q 8. Consider the code below and determine the output -
int main()
{
int i = 0;
int k = ++i;
printf ("%d", k);
}
A. 1
B. 0
C. 2
D. indeterminate
  A - B - C - D
Soln. Ans: a
Evaluation:

Q 9. Consider the code below and determine the output -
int main()
{
int i = 0;
int k = ++i + i++;
printf ("%d", k);
return 0;
}
A. 1
B. 0
C. 2
D. indeterminate
  A - B - C - D
Soln. Ans: d
- sequence point violations
Evaluation:

Q 10. Consider the code below and determine the output -
int main()
{
int i = 0;
int k = ++i;
printf ("%d-%d", k++, ++k);
return 0;
}
A. 0-2
B. 1-2
C. 1-3
D. indeterminate
  A - B - C - D
Soln. Ans: d
- sequence point violations
Evaluation:

My C/C++ Videos on Youtube

Here is the complete playlist for video lectures and tutorials for the absolute beginners. The language has been kept simple so that anybody can easily understand them. I have avoided complex jargon in these videos.