I've been trying to figure out this problem for a week.
I've searched all sites for if else statements, and I can't figure out why !!!!!!!!!!!!!!!!!
What's wrong with my statements ??
Help me out !!!!!!!!!!! please.

using namespace std;

void main()
    char hsg;   //Highschool Graduate
    char hs=0;  //Highschool Student
    string prince;  //Pricipal

        cout << "\n" << "Are you in Highschool now ?(y or n) : ";
        cin >> hs;

        if(hs == 'y')

[COLOR="Red"]Problem Start from here :[/COLOR]

                cout << "\n" << "Do you have principal's permission ?(y or n) : ";      
                cin >> prince;

                if(prince == 'y')
                    cout << "Then, you are able to take class.\n";

                else if(prince == 'n')
                    cout << "Bring the permission letter from your Pricipal.\n";
            }while(!(prince == 'y' || prince == 'n'));

[COLOR="red"]Problem Finish here :[/COLOR]


        else if(hs == 'n')
            cout << "\n";
            cout << "Are you a Highschool Graduate ?(y or n) : ";
            cin >> hsg;
    }while(!(hs == 'y' || hs == 'n'));

Edited by mike_2000_17: Fixed formatting

8 Years
Discussion Span
Last Post by donaldw

Looks like prince is a string and you're comparing it to a character? Use double quotes rather than single quotes.

That was keeping it from compiling; was that all you wanted help with, or did you need help with the logic also?

Edited by donaldw: n/a


LOL what a stupid mistake !!!!!!!!!!
Thanks !!!!!!!!!!!!!!!
Really !!!!!!!!!!!!!!!!!!


No problem, it's late. Don't forget to mark the thread as solved so you don't get a hundred more replies with the same answer. A +1 wouldn't be so bad either :) lol


How do I mark the thread as solved ?
I'm newbie.......... lol sorry.


At the bottom of the thread, beside the big yellow "Reply to this thread" button there should be text to the right of it that says "mark as solved."

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.