15,746,652 members
See more:
i have to write a program to print me if the imput is 1,3,5 something..if it is 2,4,6 something else..i wrote this :

```#include <stdio.h>
int main() {
int a , b , c ,d ;
scanf("%d %d %d %d" , &a ,&b , &c , &d);
if{a=1,3,5}
printf("American feminine citizen");
if{b=2,4,6}
printf("Foreign citizen masculine");```

My question is if i wrote correctly those values in those parantheses .

What I have tried:

I searched the internet but i find solution for another similar questions
Posted
Updated 10-Nov-22 5:26am

## Solution 1

The statement :
```if{a=1,3,5}
```
is not valid C syntax. You probably want any of those values to be a true condition so you need to an OR comparison using the `||` operator. That will look like this :
C
`if( ( a == 1 ) || ( a == 3 ) || ( a == 5 ) )`
I inserted spaces and parenthesis so it is clearer and does not rely on precedence.

Bogdan Alexandru Oct2022 10-Nov-22 10:54am
ohh ok.Thank you

## Solution 2

Firstly, "=" is an assignment operator, not a comparison. Equality is tesed for with "==" instead.

Secondly, you need the AND or OR operator: && or ||
`a AND b` is true only if both conditions `a` and `b` are `true` - otherwise it returns `false`
`a OR b` is true only if either condition `a` and `b` are `true` - it returns `false` only if both are false.
For example:
C
```if (a == 1 && b == 2 && c == 3)
{
...
}```
If this isn't what you meant, then you need to explain in a lot more detail exactly what you need!

## Solution 3

Spend some time reading Elements of C | Microsoft Learn[^] as you seem to be missing the basics of the language.

## Solution 4

There are several options. If you cannot combine numbers to a range, the switch-case statement is recommended.
C
```switch(a) {
case 1:
case 3:
case 5:
printf("American feminine citizen");
break;
}
switch(b) {
case 2:
case 4:
case 6:
printf("Foreign citizen masculine");
break;
}```