Complete the class code | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Complete the class code

#include <iostream> using namespace std; class GPIO { //Complete the code here . . . . . }; int main() { GPIO ardunio(0b11011111); cout << arduino.digitalRead(0) << endl; //should print out the LSB: 1 https://code.sololearn.com/csOjOyLQ7BY8/?ref=app

29th Sep 2019, 4:13 AM
Abdelmalik Yousif
Abdelmalik Yousif - avatar
1 Answer
+ 2
this is the one : #include <iostream> using namespace std; class GPIO { string strInput; public : GPIO(string str) { strInput = str; } char digitalRead(int i) { if(i==0)//lsb { return strInput[strInput.length()-1]; } } }; int main() { GPIO ardunio("0b11011111"); cout << ardunio.digitalRead(0) << endl; //should print out the LSB: 1 return 0; }
29th Sep 2019, 4:57 AM
Ketan Lalcheta
Ketan Lalcheta - avatar