Why is the invalid letter not showing?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Robrick
    New Member
    • Feb 2012
    • 1

    #1

    Why is the invalid letter not showing?

    I wanna know why the program doesnt show "Invalid Letter Entered" when i enter any letter other than A S D or M

    Code:
    //Processing the data
    	if (letter== 'A'||'S'||'M'||'D')// checking Add, subtract, multiply or divide
    	{
    		if (letter== 'A')//Adding the integers
    			cout<<"Adding two integers = "<<first + second<<endl;
    		else if (letter== 'S')//Subtracting the integers
    		{
    			if (first < second)
    			cout<< "Subtracting two integers = "<<second - first<<endl;
    			else if (first > second)
    			cout<< "Subtracting two integers = "<<first - second<<endl;
    		}
    	
    		else if (letter== 'M')//Multiplying the integers
    			cout<<"Multiplying two integers = "<<first * second<<endl;
    		else if (letter== 'D')//Dividing the integers
    		{
    			if (first > second)
    			cout<< "Dividing two integers = "<<first/second<<endl;
    			else if (first < second)
    			cout<< "Dividing two integers = "<<second/first<<endl;
    		}
    	}
    	else
    		cout<<"Invalid Letter Entered"<<endl;
    	return 0;
    Last edited by Niheel; Feb 29 '12, 08:51 AM. Reason: You should post your question with the question.
  • Rabbit
    Recognized Expert MVP
    • Jan 2007
    • 12517

    #2
    It should be
    Code:
    if (letter== 'A' || letter== 'S'|| letter== 'M'|| letter== 'D')

    Comment

    Working...