Run ❯
Get your
own
website
×
Change Orientation
Change Theme, Dark/Light
Go to Spaces
#include
#include
using namespace std; // Declare a structure named "car" struct car { string brand; string model; int year; }; int main() { // Create a car structure and store it in myCar1; car myCar1; myCar1.brand = "BMW"; myCar1.model = "X5"; myCar1.year = 1999; // Create another car structure and store it in myCar2; car myCar2; myCar2.brand = "Ford"; myCar2.model = "Mustang"; myCar2.year = 1969; // Print the structure members cout << myCar1.brand << " " << myCar1.model << " " << myCar1.year << "\n"; cout << myCar2.brand << " " << myCar2.model << " " << myCar2.year << "\n"; return 0; }
BMW X5 1999
Ford Mustang 1969