using namespace std; struct weightType{ int pounds; int ounces; }; weightType ge
ID: 3618142 • Letter: U
Question
using namespace std;
struct weightType{
int pounds;
int ounces;
};
weightType getWeight();
weightType addWt (weightType, weightType);
int main()
{
weightType one,
two;
getWeight();
addWt(one,two);
system("pause");
return 0;
}
weightType getWeight()
{
weightType one,
two;
cout << endl << endl<<"Weight 1 is: " <<one.pounds << " pounds "<< one.ounces << "ounces." << endl;
cout <<"Weight 2 is: " << two.pounds << " pounds "<< two.ounces << "ounces." << endl;
weightType addWt (weightType one, weightTypetwo)
{
weightType three;
three.pounds = one.pounds + two.pounds;
three.ounces = one.ounces + two.ounces;
cout <<"Weight 3 (sum) is: " << three.pounds << " pounds "<< three.ounces << "ounces." << endl <<endl;
return three;
}
Explanation / Answer
please rate - thanks your problem was in getWeight-it can only return 1 thing addWeight wasn't returning anything I added a printWeight(hope you don't mind) #include #include using namespace std; struct weightType{ int pounds; int ounces; }; weightType getWeight(int); weightType addWt (weightType, weightType); void printWeight(weightType,int); int main() { weightType one,two,three; two=getWeight(2); coutRelated Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.