Question: IN C/ LINUX Implement function sub_nums that subtracts two numbers entered by the user and then prints the result of the subtraction. It first prompts

IN C/ LINUX

Implement function sub_nums that subtracts two numbers entered by the user and then prints the result of the subtraction. It first prompts the message Enter the first number:, takes a number from the user as input, and then prompts the message Enter the second number:, takes another number from the user as input, finally it subtracts the second number from the first number and prints the result. You should use the function printf to display the message, allocate memory for two null-terminated strings of length up to 9 characters using char number1[10], number2[10], and then use the function fgets to read the input into the strings, e.g. fgets(number1, sizeof(number1), stdin). You also need to declare two integers num1 and num2 using int num1, num2, and use the function atoi to convert the string number1 into the integer num1 and the string number2 into the integer num2, respectively. You can use the command man atoi to find more information on how to use the atoi function. A sample execution of the function is as below:

Enter the first number: 83 Enter the second number: 27 83 - 27 = 56.

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!