Ask Question
5 August, 05:25

Complete the function ConvertToFeetAndInches to convert totalInches to feet and inches. Return feet and inches using the HeightFtIn struct. Ex: 14 inches is 2 feet and 2 inches.

#include

typedef struct HeightFtIn_struct {

int feet;

int inches;

} HeightFtIn;

HeightFtIn ConvertToFeetAndInches (int totalInches) {

HeightFtIn tempVal;

/ * Your solution goes here * /

}

int main (void) {

HeightFtIn studentHeight;

int totalInches;

scanf ("%d", &totalInches);

studentHeight = ConvertToFeetAndInches (totalInches);

printf ("%d feet and %d inches/n", studentHeight. feet, studentHeight. inches);

return 0;

}

+3
Answers (1)
  1. 5 August, 05:53
    0
    The solution to this question with code explaination is given below in explanation section.

    Explanation:

    #include

    typedef struct HeightFtIn_struct {/ / declaring struct for feet and inches

    int feet;

    int inches;

    } HeightFtIn;

    HeightFtIn ConvertToFeetAndInches (int totalInches) {/ / function to convert to feet and in inches from total inches

    int inches = totalInches; / / declare inches local variable in ConvertToFeetAndInches function.

    int feet = inches/12; / / convert total inches into feet;

    int leftInches = inches%12; / / remaining inches after converting total inches into feet

    HeightFtIn tempVal; / / declare HeightFtIn_struct variable to store the value of inches and feets.

    tempVal. feet = feet; / / store feet value

    tempVal. inches = leftInches; / / store remaining inches after converting totalInches into feet

    return tempVal; / / return feets and inches.

    / * Your solution goes here * /

    }

    int main (void) {

    HeightFtIn studentHeight; / / declare HeightFtIn_struct variable studentHeight;

    int totalInches; / / declaring totalInches variable.

    scanf ("%d", &totalInches); / / prompt user to enter totalInches;

    studentHeight = ConvertToFeetAndInches (totalInches); / / ConvertToFeetAndInches

    printf ("%d feet and %d inches/n", studentHeight. feet, studentHeight. inches); //display converted feet and inches from totalInches;

    return 0;

    }
Know the Answer?
Not Sure About the Answer?
Find an answer to your question ✅ “Complete the function ConvertToFeetAndInches to convert totalInches to feet and inches. Return feet and inches using the HeightFtIn struct. ...” in 📘 Computers and Technology if you're in doubt about the correctness of the answers or there's no answer, then try to use the smart search and find answers to the similar questions.
Search for Other Answers