Ask Question

Write the definition of a function named alternator that receives no parameters and returns true the first time it is invoked, returns false the next time it is invoked, then true, false and so on, alternating between true / false on successive invocations.

+2
Answers (1)
  1. 20 October, 13:23
    0
    Visual C + + Programming is the software where the function defined in the question can be used. The return type of the Boolean method is applied. This is the code for the function.

    bool newbie ()

    {

    static bool x = true;

    if (x) {

    return true;

    } else {

    return false;

    }

    }
Know the Answer?
Not Sure About the Answer?
Find an answer to your question 👍 “Write the definition of a function named alternator that receives no parameters and returns true the first time it is invoked, returns ...” in 📗 Computers & Technology if the answers seem to be not correct or there’s no answer. Try a smart search to find answers to similar questions.
Search for Other Answers