Task using C language One common way of verifying if the data integrity of a file was preserved during a copy or transmission is to verify if the checksum matches. The checksum is a small piece of data computed from the original data. Your task is to compute a recursive function that maps an integer into a single digit to be used as checksum. Given an input integer in the range from 0 to 1012, the checksum is the sum of the digits of the input number. While the resulting sum has multiple digits, the checksum will

C++ for Engineers and Scientists
4th Edition
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Bronson, Gary J.
Chapter8: I/o Streams And Data Files
Section: Chapter Questions
Problem 8PP: (Data processing) A bank’s customer records are to be stored in a file and read into a set of arrays...
icon
Related questions
Question

Task using C language

One common way of verifying if the data integrity of a file was preserved during a copy or transmission is to verify if the checksum matches. The checksum is a small piece of data computed from the original data. Your task is to compute a recursive function that maps an integer into a single digit to be used as checksum. Given an input integer in the range from 0 to 1012, the checksum is the sum of the digits of the input number. While the resulting sum has multiple digits, the checksum will be the sum of its digits instead. For instance:

  • if the input is 34, the checksum is 7 (3+4);
  • if the input is 99, the sum of its digits is 18 (9+9), so the checksum is 9 (1+8);
  • if the input is 99999999999, the sum of its digits is 99 (9+9+9+9+9+9+9+9+9+9+9), whose sum of digits is 18 (9+9), so the checksum is 9 (1+8).

Requirements

  1. Follow the format of the examples below.
  2. Make sure your variables and parameters have the correct data types.
  3. You must implement a recursive function to compute the checksum. This function can have only one parameter.
  4. You are not allowed to use forwhile, and do/while in your solution.

Examples (your program must follow this format precisely)

Example #1

Input: 34
Checksum: 7

Example #2

Input: 99
Checksum: 9

Example #3

Input: 99999999999
Checksum: 9

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 4 steps with 2 images

Blurred answer
Knowledge Booster
Declaring and Defining the Function
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
Recommended textbooks for you
C++ for Engineers and Scientists
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning
Programming Logic & Design Comprehensive
Programming Logic & Design Comprehensive
Computer Science
ISBN:
9781337669405
Author:
FARRELL
Publisher:
Cengage
Systems Architecture
Systems Architecture
Computer Science
ISBN:
9781305080195
Author:
Stephen D. Burd
Publisher:
Cengage Learning