FREE! Click here to Join FunTrivia. Thousands of games, quizzes, and lots more!
Quiz about Computer Programming  C
Quiz about Computer Programming  C

Computer Programming - C++ Trivia Quiz


This quiz will test your knowledge of the semantics and syntax associated with C++ programming language.

A multiple-choice quiz by yency. Estimated time: 4 mins.
  1. Home
  2. »
  3. Quizzes
  4. »
  5. Science Trivia
  6. »
  7. Computers
  8. »
  9. Software and Programming

Author
yency
Time
4 mins
Type
Multiple Choice
Quiz #
333,297
Updated
Dec 03 21
# Qns
10
Difficulty
Average
Avg Score
6 / 10
Plays
849
- -
Question 1 of 10
1. Which of the following operators has the highest precedence? Hint


Question 2 of 10
2. Which of the following is an INVALID identifier? Hint


Question 3 of 10
3. If x = 13 and y = 5, then which of the following expressions produce a false result? Hint


Question 4 of 10
4. Which of the following data types produces an output of true/false ? Hint


Question 5 of 10
5. If PrintStars is a void function that takes an int expression as a parameter, which of the following is an INCORRECT statement?(Assume all variables are int variables.) Hint


Question 6 of 10
6. What is a function declaration without a body called? Hint


Question 7 of 10
7. A parameter that receives a copy of an argument is called a_____.
Which answer correctly completes this statement?

Hint


Question 8 of 10
8. What is a parameter that receives the location of an argument called? Hint


Question 9 of 10
9. What is wrong with the following if statement? (Assume the variable flower is a string and remember this is C++, not C)

if(flower = "Daisy")
else
Hint


Question 10 of 10
10. What is wrong with the following count-controlled loop?
int loopCount;
loopCount = 1;
int sum;
sum = 0;
while(loopCount != 10)

sum = sum + loopcount;
Hint



(Optional) Create a Free FunTrivia ID to save the points you are about to earn:

arrow Select a User ID:
arrow Choose a Password:
arrow Your Email:




Most Recent Scores
Jul 11 2024 : turtle52: 3/10
Jun 26 2024 : gracious1: 7/10

Score Distribution

quiz
Quiz Answer Key and Fun Facts
1. Which of the following operators has the highest precedence?

Answer: !

According to the rules of operator precedence in C++ "!" has the highest precedence and "=" has the lowest precedence of the operators mentioned in this question.
2. Which of the following is an INVALID identifier?

Answer: Total_in_$

In order to prevent confusion, some rules are applied to the naming of identifiers. For example, identifiers are not allowed to have blanks such as "Total Cost." Identifiers cannot be named after reserved words such as int, float, const, enum, etc. Special symbols such as "$" and "@" are not allowed.
3. If x = 13 and y = 5, then which of the following expressions produce a false result?

Answer: x+7 != y*4

The relational operator ! means NOT in C++. Therefore, given the values of x and y, the expressions "x+7 != y*4" produces a result of false.
4. Which of the following data types produces an output of true/false ?

Answer: bool

Variables of type bool can contain either true or false, but nothing else.
5. If PrintStars is a void function that takes an int expression as a parameter, which of the following is an INCORRECT statement?(Assume all variables are int variables.)

Answer: Stars = PrintStars(Num)

A void function does not return a value to its caller. Therefore the statement "Stars = PrintStars(Num)" would be incorrect and would produce an error in the program.
6. What is a function declaration without a body called?

Answer: Function prototype

A function prototype is used to declare a function before the latter is defined. A body is not included.
7. A parameter that receives a copy of an argument is called a_____. Which answer correctly completes this statement?

Answer: value parameter

A value parameter receives a copy of an argument so if the value is changed in one function, another function with the same value would not change.
8. What is a parameter that receives the location of an argument called?

Answer: reference parameter

A reference parameter receives the location or the memory address of the caller's argument. It is declared by attaching an ampersand(&) to the name of a data type.
9. What is wrong with the following if statement? (Assume the variable flower is a string and remember this is C++, not C) if(flower = "Daisy") else

Answer: "=" should be "=="

It's common to mistake the assignment operator (=) with the relational operator(==). These two operators do very different things in C++.
10. What is wrong with the following count-controlled loop? int loopCount; loopCount = 1; int sum; sum = 0; while(loopCount != 10) { sum = sum + loopcount; }

Answer: no incrementation

If the value of loopCount is not incremented, the loop will never exit because the value of loopCount will not fulfill the termination condition.
Source: Author yency

This quiz was reviewed by FunTrivia editor crisw before going online.
Any errors found in FunTrivia content are routinely corrected through our feedback system.
7/12/2024, Copyright 2024 FunTrivia, Inc. - Report an Error / Contact Us