Answer to Question #299135 in C++ for Rival

Question #299135

Objective:

Write a program that uses a structure named Student to store the following information about a student:

• Student ID

• Student Name

• Major

• Year Passed

The program should create two Student variables, store values in their members, and pass each one, in turn, to a function that displays the information about the student in a clearlv formatted

manner.


1
Expert's answer
2022-02-17T11:52:28-0500
#include <iostream>
#include <string>


using namespace std;




struct Student{
	int ID;
	string Name;
	string Major;
	int YearPassed;
};




void display(Student student){
	cout<<"Student ID: "<<student.ID<<"\n";
	cout<<"Student Name: "<<student.Name<<"\n";
	cout<<"Student Major: "<<student.Major<<"\n";
	cout<<"Student year passed: "<<student.YearPassed<<"\n\n";
}


int main() {
	Student student1;
	student1.ID=546;
	student1.Name="Mike";
	student1.Major="Major";
	student1.YearPassed=3;


	Student student2;
	student2.ID=789;
	student2.Name="Mary";
	student2.Major="Major 5";
	student2.YearPassed=2;




	display(student1);
	display(student2);




	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