Can you please give example on statemachine either even or odd?

can you please give example on state machine either even or odd with best practices mutiple examples.

Hi @Abhilash_Yadav

Go through the docs below which contains an example

For Even or Odd you can just change the flow this way

1. Variables (in Main.xaml):

  • number: Int32 (set this to a number like 5 in the Start state)

2. Start State (State: Start)

  • Assign number = 5 (or use Input Dialog to get user input)
  • Transition: → CheckNumber

3. CheckNumber State

  • No activities, only transitions:
    • Condition: number Mod 2 = 0 → to Even
    • Condition: number Mod 2 <> 0 → to Odd

4. Even State

  • Activity: Message Box"The number is Even"
  • Transition to End

5. Odd State

  • Activity: Message Box"The number is Odd"
  • Transition to End

Hope this helps :innocent:

Hey @Abhilash_Yadav
State Machine Components

  1. State: Start
  • Action: Use Input Dialog to get number from user.
  • Output: Store in variable inputNumber (Int32)

Transition → CheckEvenOdd

  • Condition: True (always proceeds)

  1. State: CheckEvenOdd
  • Action: Use Assign:
isEven = inputNumber Mod 2 = 0

Transition → DisplayResult

  • Condition: True

  1. State: DisplayResult
  • Action: Use If activity:
If isEven Then
    Message Box → "The number is EVEN."
Else
    Message Box → "The number is ODD."

Transition → End

  • Condition: True

:round_pushpin:4. Final State: End

  • No actions.

cheers