mardi 2 novembre 2021

IF STATEMENT C++ KEEPS TRIGGERING. IT KEEPS RETURNING TRUE ?? ANY IDEA [duplicate]

Where am I wrong?

#include <iostream>

using namespace std;

int main()
{
    char surge;
    
    cout << "Enter 'Y' if surge or 'N' if not: ";
    cin >> surge;
    surge = toupper(surge);
    cout << surge << endl ;
//exiting process if character inputted is not Y or N 

    if(surge != 'Y' || surge != 'N')
    {
        cout << "Invalid Character!" << endl;
        exit(100);
    }
}

Aucun commentaire:

Enregistrer un commentaire