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

The code must be written in c++ Define a struct Car. A car is identified by a ma

ID: 3569018 • Letter: T

Question

The code must be written in c++

Define a struct Car. A car is identified by a make and model (both strings) and a year (integer).

#include <iostream>
#include <cmath>
#include <string>

using namespace std;

//Do not modify anything on or above the line below this
//START_PROVIDED

    //DEFINE STRUCT HERE

//END_PROVIDED
//Do not modify anything on or below the line above this


int main()
{
    Car c1;
    c1.make = "Subaru";
    c1.model = "Legacy";
    c1.year = 2001;

    cout << c1.year << " " << c1.make << " " << c1.model << endl;

    return 0;
}

I need to writte an struct car where it says that an struct must be defined.

Explanation / Answer

#include <iostream>
#include <cmath>
#include <string>
using namespace std;
struct Car
{
   string make;
   string model;
   int year;
};

int main()
{
Car c1;
c1.make = "Subaru";
c1.model = "Legacy";
c1.year = 2001;
cout << c1.year << " " << c1.make << " " << c1.model << endl;
return 0;
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote