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];
}