Define a function SetHeight, with int parameters feetVal and inchesVal, that returns a struct of type WidthFtIn. The function should assign WidthFtIn's data member numFeet with feetVal and numInches with inchesVal.
#include <iostream>
using namespace std;
struct WidthFtIn {
int numFeet;
int numInches;
};
/* Your code goes here */
int main() {
WidthFtIn objectSize;
int feetVal;
int inchesVal;
cin >> feetVal >> inchesVal;
objectSize = SetHeight(feetVal, inchesVal);
cout << "Size: " << objectSize.numFeet << "ft " << objectSize.numInches << "in." << endl;
return 0;
}
#include <iostream> using namespace std; struct WidthFtIn { int numFeet; int numInches; }; WidthFtIn SetHeight(int feetVal, int inchesVal) { WidthFtIn size; size.numFeet = feetVal; size.numInches = inchesVal; return size; } int main() { WidthFtIn objectSize; int feetVal; int inchesVal; cin >> feetVal >> inchesVal; objectSize = SetHeight(feetVal, inchesVal); cout << "Size: " << objectSize.numFeet << "ft " << objectSize.numInches << "in." << endl; return 0; }
Get Answers For Free
Most questions answered within 1 hours.