if statement

1
2
3
4
5
int n;
if (n != 1, 2,10)
    {
          cout << "Hello World";
    }


the output should be "hello world" if "n" is "not equal" to 1 or 2 or 10.
that code doesnt work(hello world will still be the output even if "n" is equal to 1 or 2 or 10)..can any one help me wtih this??...i tried or, &&, n !=(1,2,10)...etc

it doesnt work

thanks in advance
if (n != 1, 2,10)

I expect you mean

if ((n != 1) && (n != 2) && (n!=10))
Last edited on
yes..thank you
Topic archived. No new replies allowed.