Problem 2. Distance Conversion (30 points) Distance is measured using various un
ID: 3748856 • Letter: P
Question
Problem 2. Distance Conversion (30 points) Distance is measured using various units like inches, feet, yards etc. Write a program that takes inches as inputs and converts it to corresponding yards, feet and inches. Remember the following conversion: 1 ft 12 in 1 yd 3 ft Sample Input and Output: (Your code should print the red texts on the screen. Black texts are sample user inputs) Sample Input Sample Output Input Inches: 478 Input Inches: 27 Input Inches: 53 478 inches 13 yards, O feet and 10 inches 29 inches 0 yards, 2 feet and 3 inches 53 inches 1 yards, 1 feet and 5 inchesExplanation / Answer
#include <stdio.h>
int main(void) {
printf("Input inches: ");
int inches;
scanf("%d", &inches);
int yards = inches / 36;
printf("%d inches = %d yards, ", inches, yards);
inches = inches % 36;
int feet = inches / 12;
printf("%d feet, ", feet);
inches = inches % 12;
printf("%d inches", inches);
return 0;
}
/*SAMPLE OUTPUT
Input inches: 27
27 inches = 0 yards, 2 feet, 3 inches
*/
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.