GPIO State Enum

#include <iostream>
#include <cstdint>
using namespace std;

// your code here: declare enum class PinState with values Low, High
enum class PinState{
   Low,
   High
};

const char* toString(PinState s) {
	// your code here: implement toString(PinState s)
   switch(s)
   {
      case PinState::Low:
         return "LOW";
   case PinState::High:
         return "HIGH";
   }
   
}


int main() {
   int x;
   cin >> x;
   PinState s = (x == 0) ? PinState::Low : PinState::High;
   cout << toString(s);
   return 0;
}
Upvote
Downvote
Loading...

Input

0

Expected Output

LOW