Write a code to return the following structure from function:
Structure name is Patientand haveTHE following members.
Name, cnic, sugar_level.
#include <iostream>
#include <string>
using namespace std;
struct Patient{
string name;
string cnic;
string sugar_level;
};
struct Patient getPatient(){
struct Patient newPatient;
cout<<"Enter patient name: ";
getline(cin,newPatient.name);
cout<<"Enter patient cnic: ";
getline(cin,newPatient.cnic);
cout<<"Enter patient sugar level: ";
getline(cin,newPatient.sugar_level);
return newPatient;
}
int main(){
struct Patient patient=getPatient();
cout<<"\nThe patient name: "<<patient.name<<"\n";
cout<<"The patient cnic: "<<patient.cnic<<"\n";
cout<<"The patient sugar level: "<<patient.sugar_level<<"\n";
system("pause");
return 0;
}
Comments
Leave a comment