Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

New to MATLAB?

Thread Subject:
Even number/Odd number if statement

Subject: Even number/Odd number if statement

From: Stuart

Date: 6 Dec, 2010 10:50:05

Message: 1 of 1


Currently im writing a code for fun that simulates a roulette wheel. i have coded it such that i can choose a number to bet on and it works fine. however it doesnt work when i tell it to bet odd or even.

The if statement im using contains these lines
if bet_number ==33
    if mod(Result+1,2)
       Cash = Cash + bet;
        Cash = Cash - bet;
if bet_number ==34
    if mod(Result,2)
       Cash = Cash + bet;
        Cash = Cash - bet;

bet_number ==33 denotes bet all odd numbers
bet_number ==34 denotes bet all even numbers

this combined with the rest of my script doesnt seem to work.

are there alternate functions i can uses as an if statement for if this is odd or if this is even, do this instead of mod

Tags for this Thread

No tags are associated with this thread.

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us