this is the question:
Problem Description
An artist wants to construct a sign whose letters will rotate freely in the breeze. In order to do this,
she must only use letters that are not changed by rotation of 180 degrees: I, O, S, H, Z, X, and N.
Write a program that reads a word and determines whether the word can be used on the sign.
Input Speciļ¬cation
The input will consist of one word, all in uppercase letters, with no spaces. The maximum length
of the word will be 30 letters, and the word will have at least one letter in it.
Output Speciļ¬cation
Output YES if the input word can be used on the sign; otherwise, output NO.
Sample Input 1
SHINS
Output for Sample Input 1
YES
Sample Input 2
NOISE
Output for Sample Input 2
NO
and this is my code[#include <iostream>
#include <string>
using namespace std;
int main()
{
string x;
cin>>x;
bool condition;
for(int i=0;i<x.length();i++)
{
if(x[i]!='I'||'O'||'S'||'H'||'Z'||'X'||'N')
{
condition=false;
}
}
if (condition=false)
{
cout<<"NO";
}
else
{
cout<<"YES";
}
system("pause");
}
]
please tell me whats wrong with this code ? thanks
all your if statements are causing the problem. The first if statement only compares x[i] to 'I', the second if statement assigns the Boolean value false to condition so the program always outputs "YES"