Having some trouble

I wrote this code to automatically call the U.S. based on the area code of the phone number, but can't figure out what the error means.

>#include <iostream>
>using namespace std;
>
>int main (void)
>{
> int statesphone1 =917;
> int statesphone2 = 716;
> int statesphone3 = 512;
> int phone;
>
>cout << "Enter phone number now: " << endl;
> cin >> phone;
> if (phone == statesphone1 || statesphone2 || statesphone3)
> cout << "1-(688)-466-3-" << phone << " | number dialed." << endl;
>
> else if (phone != statesphone1 || statesphone2 || statesphone3)
> cout << phone << endl;
>return 0;
>}

Any help would be appreciated.
but can't figure out what the error means.
And what is the error?

This if (phone == statesphone1 || statesphone2 || statesphone3) is wrong it must be if (phone == statesphone1 || phone == statesphone2 || phone == statesphone3)
Thanks coder. That worked perfectly.

I am now having a problem with getting the program to ignore spaces and dashes.

#include <iostream>
using namespace std;

int main (void)
{
int statesphone1 =917;
int statesphone2 = 716;
int statesphone3 = 512;
int phone;

cout << "Enter phone number now: " << endl;
cin >> phone;
if (phone == statesphone1 || phone == statesphone2 || phone == statesphone3)
cout << "1-(688)-466-3-" << phone << " | number dialed." << endl;

else if (phone != statesphone1 || phone != statesphone2 || phone != statesphone3)
cout << phone << endl;
return 0;

}

As before, any help would be appreciated.
cin >> phone;does not allow spaces and dashes. Or do you mean that you want to enter that then you need to string phone;
Topic archived. No new replies allowed.