Need help

Hello guys, this is a program I made from scratch, I know it's a simple program but I'm still new with C++. Right now I'm stuck at second "for loop" where the output I wanted is not what I expected.

Here's an example:
*What I want the output to be*

*After making a list*
What is Person1 IQ test score? 1
What is Person2 IQ test score? 2
What is Person3 IQ test score? 3

*What the output gave me instead*

*After making a list*
What is Person1 IQ test score? 1
What is Person1 IQ test score? 2
What is Person1 IQ test score? 3

I've been stuck at this problem for at least an hour now.


#include <iostream>
#include <string>

using namespace std;

int main() {
int IQ_test[100];
int numOfPeople;
string Name;
string nameOfPeople[100] = {Name};

cout << "How many people are there?" << endl;
cin >> numOfPeople;

cout << "The listed people are: " << endl;
for(int i = 0; i <= numOfPeople; ++i) {
getline(cin, Name);
}

cout << "First question is... IQ Test." << endl;
for(int i = 0; i <= numOfPeople; ++i) {
if(i <= numOfPeople) {
cout << "What is " << Name << " IQ test score? "; //Stuck over here
cin >> IQ_test[i];
cout << endl;
}
}

int Highest = IQ_test[0];
int Lowest = IQ_test[0];
cout << "Checking for the highest IQ..." << endl;
cout << "Checking for the lowest IQ..." << endl;

for(int i = 1; i <= numOfPeople; ++i) {
if(Highest < IQ_test[i]) {
Highest = IQ_test[i];
}

if(Lowest > IQ_test[i]) {
Lowest = IQ_test[i];
}
}
cout << "Who got the IQ?" << endl;
cout << Highest << endl;
cout << "Who got the lowest IQ?" << endl;
cout << Lowest << endl;


}
Last edited on
Well, I was using "Person1, Person2 and etc" as an example.
Like I wanted to have a different name like this:

What is Jason IQ test score? 1
What is Chris IQ test score? 2
What is Taylor IQ test score? 3

Sorry for not being specific about it.
Last edited on
Well...
The output I got now is...

What is IQ test score?

But I think I got it. Thanks for helping me :)
Topic archived. No new replies allowed.