It is given that the feetVal and inchesVal are parameters of the SetHeight() function. Since the return type of the function is structute, so we need to define a structure.
After that, we need to create a structure variable within the function definition. Now, assign the feet and inches with the feetVal and inchesVal respectively. Finally return the structure variable.
Further explanation:
#include<stdio.h>
//define the structure
typedef struct HeightFtIn_struct {
int feet;
int inches;
} HeightFtIn;
//define the function
HeightFtIn SetHeight(int feetVal, int inchesVal)
{
HeightFtIn Htft; //creating a structure variable of type HeightFtIn
//assign the value of feetVal
Htft.feet = feetVal;
Htft.inches = inchesVal; //assigning the value of inchesval
//return the structure variable
return Htft;
}
int main(void) {
HeightFtIn studentHeight;
int feet;
int inches;
printf("Enter the values of feet and the inches: ");
scanf("%d %d", &feet, &inches);
studentHeight = SetHeight(feet, inches);
printf("The student's height is %d feet and %d inches.\n", studentHeight.feet, studentHeight.inches);
return 0;
}
Output:
Enter the values of feet and the inches: 5 9
The student's height is 5 feet and 9 inches.
Learn more:
1. A company that allows you to license software monthly to use online is an example of ? brainly.com/question/10410011
2. How does coding work on computers? brainly.com/question/2257971
Answer details:
Grade: College Engineering
Subject: Computer Science
Chapter: C Programming
Keyword:
C++, input, output, programming, statements, loops, if, else, statements, firstname, lastname, base class, derive class, vector, print