Question: PROGRAM C Add three lines of code to convert the three chars to an integer using sum. Because the three chars must be converted to

PROGRAM C

Add three lines of code to convert the three chars to an integer using sum. Because the three chars must be converted to integer values, you should subtract either '0' or 48. The a char is hundreds, the b char is tens and the c char is ones. Test your code by calling the function from main. After it runs correctly, comment the call in main and start the next problem: 7.

The output should look like below for function call chars_to_int4('1', '2', '3'):

a = 1 b = 2 c = 3 a = 1 b = 2 c = 3 chars_to_int4 = 123

The first and second lines above should be printed in the chars_to_int4 function. The second line above should be printed in the main function. */

int chars_to_int4(char a,char b, char c){ int sum = 0; printf("a = %c b = %c c = %c ", a, b, c); printf("a = %d b = %d c = %d ", a-'0', b-48, c-'0'); return sum;

}

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!