1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
MA_775_DIABLO [31]
2 years ago
10

Write the definition of a function named alternator that receives no parameters and returns true the first time it is invoked, r

eturns false the next time it is invoked, then true, false and so on, alternating between true/false on successive invocations.
Computers and Technology
1 answer:
Nataly [62]2 years ago
3 0

Answer:

The solution code is written in C++

  1. bool STATUS = true;
  2. bool alternator ()
  3. {
  4.    if(STATUS){
  5.        STATUS = false;
  6.        return true;
  7.    }else{
  8.        STATUS = true;
  9.        return false;
  10.    }
  11. }

Explanation:

We need a global variable to track the status of true or false (Line 1).

Next, create the function alternator (Line 2) and then check if current status is true, set the status to false but return the previous status boolean value (Line 5-6). At the first time of function invocation, it will return true.

The else block will set the STATUS to true and return the false (Line 7-9).

You might be interested in
How does a spreadsheet affect a column of numerals when it sorts the column
maria [59]

Explanation/Answer:

Data can be put into more than one cell (Excel), which should be an important key to your answer. In SEVERAL CELLS AT THE SAME TIME or more. The data can be entered in dates, text, times, or numbers. Formatting the data can be done in a possibility of ways.

6 0
3 years ago
Read 2 more answers
Which option identifies what the computer will yield in the following scenario?
dolphi86 [110]
I think it would be the computer program will create a design with the exact dimensions
6 0
2 years ago
• In your response, please include some examples of the three different types of storage.
babunello [35]
Hard Disk Drive
Solid State Drive
And Random Access Memory (RAM)
6 0
3 years ago
Read 2 more answers
Which is a benefit of owning a desktop computer instead of a laptop?
Setler79 [48]
B) a desktop is less likely to be stolen or damaged
4 0
3 years ago
Read 2 more answers
What is a popular use for SLR film cameras? (choose one)
Artemon [7]
Answer is c i believe
3 0
3 years ago
Other questions:
  • You can use the_______key if your cursor is at the end of the word. Use the______key if you place the cursor on the left side of
    11·1 answer
  • Craig's annual take-home pay is $75,000. What is the maximum amount that he can spend per month paying off credit cards and loan
    7·2 answers
  • Is there such a thing as an ethical reason for unauthorized access into a computer system?
    15·1 answer
  • Instructions:Type the correct answer in the box. Spell all words correctly.
    14·2 answers
  • A senior center would like to add a new computer to their library so that members can check their email and read book reviews
    11·2 answers
  • Describe one type of technology that is useful in producing images from space.
    9·1 answer
  • Which of these forms of multimedia would most likely contain both music and text:
    14·1 answer
  • Why does brainly keep saying “oops... something went wrong! Try again”
    7·2 answers
  • What is GND and what color wire do we connect to GND? (this is like for circuits and stuff btw)
    7·1 answer
  • Name 4 components of a components system​
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!