Question: 1. Below is a function used to convert a digit character to an integer that represents its numerical value. a. Improve the function so that

 1. Below is a function used to convert a digit character

1. Below is a function used to convert a digit character to an integer that represents its numerical value. a. Improve the function so that if a character that does not represent a digit is passed, the function returns -1 to indicate an error. b. Properly comment the function. See slide 10 of lecture 5 for a description of how to properly comment the function. What would you put in the .h (header) file and .c (implementation) file of a library so that others may use it in their program? int char_to_int (char chl) return chi - Ox30; 2. The following code does not compile. Find the error and describe the rule that is being broken. uint16_t add(uint16_t a, uint16_t b, uint16_t c) a a += b; += c; uint16_t average = a/3; return a; void setup() { // put your setup code here, to run once: Serial.begin(9600); void loop() { // put your main code here, to run repeatedly: uint16_t sum = add (4, 6, 8); Serial.print("The sum is: "); Serial.println (sum); Serial.print("The average is: "); Serial.println(average)

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!