No history yet

Final Exam

 

1.Using a standard 12-hour clock, if it is 9 o'clock now, what time will it be in 5 hours? This is an example of what operation?

 

2.In the expression a mod n = r, what is the term 'n' called?

 

3.What is the result of the following C++ 14 expression? 25 % 7

 

4.In C++, how does the integer division operator (/) differ from the modulo operator (%) when used with positive integers like 13 / 5 and 13 % 5?

 

5.You have an array of 10 elements (indexed 0 to 9). Which expression correctly finds the index that is 4 positions after index 8, wrapping around if necessary?

 

6.Which property correctly describes modular addition?

 

7.Why is the property (a + b) % n = ((a % n) + (b % n)) % n particularly useful in programming with fixed-size integers (like int)?

 

8.In C++, the expression (-5 % 12) might evaluate to -5. How do you correctly normalize this result to be within the range [0, 11]?

 

9.What is the value of (15 * 10) % 7?

 

10.In a hash table, the modulo operator is often used to:

 

11.The Caesar Cipher, a simple substitution cipher, shifts each letter of the alphabet by a certain number of places. If you shift the letter 'Y' (24th letter) forward by 4 places in the 26-letter English alphabet, what is the resulting letter?

 

12.What is the primary danger of calculating (a * b) % n in C++ by first computing a * b when a and b are large?

 

13.True or False: If two numbers a and b have the same remainder when divided by n, they are said to be 'congruent modulo n'.

 

14.What is the result of the expression (100 - 55) % 9?

 

15.Which of these C++ code snippets correctly implements a function for modular subtraction that always returns a positive result in the range [0, m-1]?

All done? Get your grade