Answered step by step
Verified Expert Solution
Question
1 Approved Answer
C . Using printf / scanf In this program, you will add two user entered heights in feet'inches format ( eg: 5 ' 1 0
C Using printfscanf
In this program, you will add two user entered heights in feet'inches" format eg: and print the sum of the two heights in the feet'inches" format as well as in centimeters. Write your C program called LabCcpp that does the following:
Prompt for and read in first height using printf and scanf appropriately. Use integer variables to store feet and inches for the first height feet and inches You need to use the correct format specifier in scanf to scan the two values. Hint: See lecture slide coding examples Chapter
Prompt for and read in second height using printf and scanf appropriately. Use integer variables to store feet and inches for the second height feet and inches
Compute the sum of the two user entered heights.
For calculating sum in feet'inches" format, add two feet and two inches of the two heights in two integer variables totalFeet and totalinches Also, compute the carryover after you sum the inches of the two heights because foot inches. For example, if user enters and for first and second heights respectively, then the sum should be instead of
Hint: Although you may use different techniques to solve this problem, you can use integer division operation to the sum of inches to get the carryover part and add the carryover to the total feet. Also, apply modulo operation to the sum of inches to compute the total inches.
CSCE Lab
For calculating sum in centimeters use floating point variable totalCenti you can use the following formula note: foot centimeters and inch centimeters:
totalCenti totalFeet totalinches
Print the summation of the two heights in feet'inches" and centimeters units using printf function:
Display centimeters with precision of ie two digits after dot
Sample outputs:
$aout
Enter first height format: :
Enter second height format: :
Sum of two heights centimeters
$aout
Enter first height format: :
Enter second height format: :
Sum of two heights centimeters
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started