Why isnt this program working properly?

For college practice for our midterm this week our teacher gave us a bunch of programs to create to get us prepared for the test
so i created a few of them so far but i was just having trouble with the following
we need to create a program that has a bunch of phone numbers hardcoded into a vector and then ask the user to enter in any of the phone numbers and if the entered number matches one of the numbers in the vector then the program terminates. So i created a nested loop to accomplish this but its not working,it always outputs that the number entered is home's number. Can anyone help please?
vector <double> v1;

int i = 0;
bool b = false;
while(b != true)
cout << "Enter in one of the family's phone numbers and we will tell you if it is correct: ";
double num;
cin >> num;
for(unsigned i = 0; b!=true; ++i)
if(num == v1[i])
b = true;
string name;
if (i == 0) {
name = "Home";
} else if(i==1)
name = "Alex";
} else if(i==2)
name = "Chris";
} else if(i==3)
name = "Mom";
} else if(i==4)
name = "Sophie";
cout << endl;
cout << "That number is " << name << "'s number ";
You have two variables named i in the program. The first one int i = 0; will always be 0 so that is why it prints "Home". The second one unsigned i = 0; is defined inside the for loop. It is only used inside that loop.
Topic archived. No new replies allowed.