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]
3 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]3 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
In an ethernet network, a(n) _____ data transmission is one that can transmit data in both directions at the same time.
Sladkaya [172]
Full-Duplex is data flow that can travel in two directions at the same time. 
Half-Duplex is data flow that can travel in two directions but not at the same time.
Simplex is data flow that can only travel in one direction.
7 0
4 years ago
Need help with 3.2 lesson practice questions (edhesive)​
Vinvika [58]

Answer:

<h2>Doesn't have a question</h2>

Explanation:

<h2 /><h2>THANK YOUU</h2>
7 0
3 years ago
While the names for Web addresses, or URLs, are not case-sensitive, the names for files you create for the Web are. 
gtnhenbr [62]
90% sure the answer isTrue
6 0
4 years ago
What is wrong with this case statement -&gt; case 2:
PtichkaEL [24]

Answer:

C: Nothing

Explanation:

Assuming this case is acting upon a switch on an integral value, there is nothing wrong with this case header.

var x = 10;

switch (x)

{

case 2:

     Console.WriteLine("The value of 'x' is 2!");

}

4 0
2 years ago
Which of these is an.optical medium of storage?
makkiz [27]
Do you have some answer choices?
8 0
3 years ago
Other questions:
  • Which of the following careers is part of the Printing Technology pathway?
    10·1 answer
  • When a user logs on to a windows 7 computer using remote desktop, users that are logged on locally are unaffected.?
    10·1 answer
  • Mila received a new DVD player that she is trying to connect to the back of her television by feel alone. The first stage of mem
    11·1 answer
  • A palindrome is any word, phrase, or sentence that reads the same forward and backward. Here are some well-known palindromes: Ab
    11·1 answer
  • Which of the following defines what privacy policy is?
    6·2 answers
  • a machine needs a minimum of 100 sec to sort 1000 names by quicksort what is the approximate worst case time needed to sort 100
    13·1 answer
  • Cuál ha sido el papel de las tecnologías de la información y los medios de comunicación en el fenómeno de la globalización​
    10·1 answer
  • A sum of money is shared between 2 friends in the ratio 2 : 3. If the larger
    9·1 answer
  • How does a fully integrated Data and Analytics Platform enable organizations to convert data into consumable information and ins
    15·1 answer
  • John is directing a television series. He has to shoot a scene that presents the lead character in a dominating and commanding p
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!