Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write a function that converts an input of some integer number of inches into ou

ID: 3541153 • Letter: W

Question

Write a function that converts an input of some integer number of inches into outputs of integer numbers of yards, feet, and inches.  Do not write a main function. Your function does not do cin or cout. Your function will have four parameters. Make sure you use appropriate parameter passing techniques! Your function will be a void function. There are 12 inches in a foot, and 36 inches in a yard.  For example, if the total number of inches input is 50, the results are 1 yard, 1 foot, and 2 inches.

Explanation / Answer

#include<iostream>
using namespace std;
void convert(int inches,int& yard,int& foot,int& left)
{
yard = (inches/36);
inches = inches-36*yard;
foot = (inches/12);
inches = inches-12*foot;
left = inches;
}
int main()
{
int inches = 50;
int yard = 0;
int foot = 0;
int left = 0;
convert(50,yard,foot,left);
cout <<inches << " inches equal to ";
cout << yard <<" yard, " <<foot <<" foot, and "<< left <<" inches. " << endl;
return 0;
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote