Operators Quiz


Identification:

Last Name:     

First Name:    

Class Section: 

Matching

Type the letter of the term which best matches the following descriptions:

Terms
a) : ? b) -= c) *= d) ? :
e) /= f) = g) == h) +=

Descriptions
1. Adjusts value of variable by subtracting 2. Adjusts value of variable by multiplying 3. Assignment Operator
4. Adjusts value of variable by adding 5. Adjusts value of variable by dividing 6. Conditional Operator

Put the letter of the best answer for the following:

7. Which of the following statements will add 5 to the
current value of A?

a. A + 5 = A;
b. A = A += 5;
c. 5 += A; 
d. A += 5;
e. += 5 A;
Answer:  

8. Which of the following will multiply the current value 
of G by 3?

a. G = G *= 3;
b. *= 3 G;
c. G * 3 = G;
d. 3 *= G; 
e. G *= 3;
Answer:  

9. The Conditional Operator is most similar to:

a. an assignment statement
b. an if statement
c. an if else statement
d. a loop
e. none of the above
Answer:  

10. Which of the following means:
if T is greater than 65 print "Speeding", otherwise
print "Speed is OK".

char str1[] = "Speeding";
char str2[] = "Speed is OK";

a. printf("%s\n", (T > 65) : str1 ? str2);
b. printf("%s\n", (T > 65) ? str1 : str2);
c. (T > 65) printf("%s\n", : str1 ? str2);
d. (T > 65) printf("%s\n", ? str1 : str2);
e. none of the above
Answer:  

11. Which of the following means:
K gets assigned 14 if Letter is equal to 'J', but
K gets assigned 25 if Letter is not equal to 'J'.

a. K = (Letter = 'J') ? 14 : 25;
b. K = (Letter == 'J') : 14 ? 25;
c. K = (Letter = 'J') : 25 ? 14;
d. K = (Letter == 'J') ? 25 : 14;
e. none of the above
Answer: