// power cycle computer bool was_on = set_computer_on(true); // returns prior value if (was_on) { set_computer_on(false); set_computer_on(true); } else { // was previously off, is now on: nothing to do! }