Program Control
A checksum is a simple way to protect the integrity of data by detecting errors that might occur when the data are communicated. It works by adding up the basic components of a datum and storing the resulting value. Anyone can later perform the same operation on the datum, compare the result to the authentic checksum, and (assuming that the sums match) conclude that the datum is probably not corrupted. For example, suppose Person A wishes to communicate the number "752" to Person B via a very poor satellite phone connection. A simple checksum algorithm might involve adding the digits of this number and reporting the ones' digit of the sum. So, since 7 + 5 + 2 = 14, the checksum for 752 is 4. Person A then reads both numbers 752 and 4 into the phone. At the other end of the connection Person B writes down what he thinks he hears as the two numbers, adds together the digits of the first number and checks that their sum is the same as the second number. If the sum is the same then there's a good chance that the number was communicated correctly, otherwise Person B will ask for the number to be communicated again. Activity 7.1 Suppose that Person B mishears the first number but correctly hears and writes down the checksum number, 4. Using the number entry tool below, provide an example of a number of three or more digits that contains none of the digits 7, 5 or 2, but that is such that it would lead Person B to think he had received the correct number. Activity 7, Question 1 Target checksum: 4 Number: 400 Score: 1 / 1 Submitted: 10/23/2016 10:08pm Activity 7.2 Array aof ints contains the digits of a number. Complete the following code to store in the variable checksumthe checksum of this number calculated using the algorithm described above
Información del documento
- Subido en
- 12 de noviembre de 2022
- Número de páginas
- 5
- Escrito en
- 2022/2023
- Tipo
- Examen
- Contiene
- Preguntas y respuestas