Current location - Training Enrollment Network - Mathematics courses - What does if(n%2) mean in C language?
What does if(n%2) mean in C language?
If(n%2) means: If n is not divisible by 2;

If it is the identification of the judgment statement;

Use c language! =0 can be omitted;

N%2 is equivalent to n%2! =0; Judging whether the integer n is odd or even, if n is odd, the condition of the if statement is true, otherwise it is false;

Extended data

Structural usage of if

1, if 1 structure

If (conditions)

{

Statement1;

Statement 2;

......

}

2. The second structure of 2.if

If (condition 1)

{

Statement1;

Statement 2;

......

}

other

{

}

3. The third structure of 3.if

If (condition 1)

{

Statement1;

Statement 2;

......

}

Elseif (condition 2)

{

}

Elseif (condition 3)

{

}

Elseif (condition 4)

{

}

other

{

}