Answer to Question #215534 in C++ for Ahmed Usman

Question #215534

   Write a code to return the following structure from function:

Structure name is Patientand haveTHE following members.

                  Name, cnic, sugar_level.


1
Expert's answer
2021-07-09T03:35:22-0400
#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;
}




Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS