Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Overview This checkpoint is intended to help you practice the mechanics of struc

ID: 3695498 • Letter: O

Question

Overview This checkpoint is intended to help you practice the mechanics of structs in C++. Instructions Write a C++program according to the following: 1. Create a struct for a Student, that contains a string for a first name, a string for a last name, and an integer for an id. 2. Create a function called, displayStudent, that accepts a student struct, and displays their information in the following format: "id#-FirstName LastName" The program should do the following . Declare a Student struct called "user" 2. Prompt the user for their first name, last name, and id number, and save these values into your "user" struct 3. Pass the user struct to the display function to be displayed.

Explanation / Answer

#include <iostream>

using namespace std;

struct student{
    char fname[50];
    char lname[50];
    int id;
};

void DisplayStudent(student s){
    cout<<s.id<<" - "<<s.fname<<" "<<s.lname<<" ";
}
int main(){
    struct student s;
    cout << "Please enter your first name: ";
    cin >> s.fname;
    cout << "Please enter your last name: ";
    cin >> s.lname;
    cout << "Please enter your id number: ";
    cin >> s.id;

    cout << "Your information:"<< endl;
    DisplayStudent(s);
   return 0;
}