question

Pinakin K avatar image
0 Likes"
Pinakin K asked Roi Sánchez answered

How to check if the output of an object is an even number in code?

I want to check if the output of the queue is even or odd. How do I do it?

FlexSim 19.0.0
math
5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.

1 Answer

Roi Sánchez avatar image
3 Likes"
Roi Sánchez answered

Hi @Pinakin K, you can use "%2" to get the remainder of dividing the number by 2. If this remainder is 0, then your number will be even.

See the example:

int number = 6;
int aux = number%2;

if (aux == 0){
    //Even
}
else{
    //Odd
}
5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.