46. GPIO State Enum

Your task is to declare a scoped enum class named PinState representing the logic level of a GPIO pin.

Requirements:

  • The enum class must have the values:
    • Low
    • High
  • The enum class must use uint8_t as its underlying type.
  • Implement a function:

    const char* toString(PinState s)
    

    which returns:

    • "LOW" for PinState::Low
    • "HIGH" for PinState::High

 

The program will:

  • Read an integer input x
  • x is guaranteed to be either 0 or 1
  • Map:
    • 0 → PinState::Low
    • 1 → PinState::High
  • Print the corresponding string representation

No other input values will be provided.

 

Input / Output Specification
Input:
A single integer x where:

  • x == 0 represents a LOW GPIO state
  • x == 1 represents a HIGH GPIO state

Output:
Print exactly one of the following strings (no newline required):

  • LOW
  • HIGH

 

Example 1
Input:

0

Output:

LOW 

 

Example 2

Input:

1

Output:

HIGH

 

 

 

 

 

Loading...

Input

0

Expected Output

LOW