I want to make a program that lets the user input the brand, price and color of a car for an unknown amount of cars, and cant figure out how to do that or what i have to search for in order to understand.
Example of what i want it to do: i want 20 cars, and i want to input values for each one of them and at the end have the program say which brand is the most expensive.
#include <iostream>
using namespace std;
struct car{
char brand[50];
char color[60];
unsigned short int price;
};
void compare(car a, car b){
if(a.price > b.price)
cout << "Most expensive: " << a.brand;
else
cout << "Most expensive: " << b.brand;
}
int main()
{
car m1, m2;
cout << "Brand of first car: "; cin >> m1.brand; cout << endl;
cout << "Color of first car: "; cin >> m1.color; cout << endl;
cout << "Price of first car: "; cin >> m1.price; cout << endl << endl;
cout << "Brand of second car: "; cin >> m2.brand; cout << endl;
cout << "Color of second car: "; cin >> m2.color; cout << endl;
cout << "Price of second car: "; cin >> m2.price; cout << endl << endl;
compare(m1, m2);
return 0;
}