Declare a struct named PatientData that contains two integer data members named
ID: 3854136 • Letter: D
Question
Declare a struct named PatientData that contains two integer data members named heightInches and weightPounds. Sample output for the given program:
Patient data: 63 in, 115 lbs
#include <iostream>
using namespace std;
/* Your solution goes here */
int main() {
PatientData lunaLovegood;
lunaLovegood.heightInches = 63;
lunaLovegood.weightPounds = 115;
cout << "Patient data: "
<< lunaLovegood.heightInches << " in, "
<< lunaLovegood.weightPounds << " lbs" << endl;
return 0;
}
Explanation / Answer
#include <iostream>
using namespace std;
/* Your solution goes here */
struct PatientData{
int heightInches;
int weightPounds;
};
int main() {
PatientData lunaLovegood;
lunaLovegood.heightInches = 63;
lunaLovegood.weightPounds = 115;
cout << "Patient data: "
<< lunaLovegood.heightInches << " in, "
<< lunaLovegood.weightPounds << " lbs" << endl;
return 0;
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.