#include <iostream> using namespace std; // Define class GpioPin here class GpioPin { public: int pinNumber; // pin number (assigned manually) int pinState; // 0 = LOW, 1 = HIGH // Default constructor GpioPin() { pinState = 0; // initialize to LOW pinNumber = -1; // default invalid, will be set manually } // Write function to set pin state void write(int value) { pinState = value; } // Read function to return pin state int read() { return pinState; } }; int main() { int pin, initialValue, finalValue; cin >> pin >> initialValue >> finalValue; GpioPin gpio; // default constructor gpio.pinNumber = pin; // manual assignment gpio.write(initialValue); gpio.write(finalValue); cout << "GPIO Pin " << gpio.pinNumber << " State " << gpio.read(); return 0; }
Test Cases
Test Results
Input
13 0 1
Expected Output
GPIO Pin 13 State 1