I am learning c++ around two weeks and therefore have a lot of questions. It feels like i learn a new sport. My body in my thinking already moving much better than any other olympic players, but the actual movement is so poor.
what i want to know is if i can use "while" in cout together.
int main() {
struct {
string engineType;
string brand;
int price;
int range;
} candidate1, candidate2;
// information of candidate 1
candidate1.name = "IONIQ5";
candidate1.range = 450;
candidate1.price = 35000;
// information of candidate 2
candidate2.brand = "Tesla_Model_3";
candidate2.range = 650;
candidate2.price = 55000;
// show each price with while function
int i = 1;
while (i<3) {
cout << "Price :" << candidate[i].range << endl ;
i++;
}
return 0;
I want to have as a result of print
450
650
what do i have to do to get it ?
Thanks for the help !