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
Write an expression that executes the loop body as long as the user enters a non-negative number. Note: If the submitted code ha
madam [21]

Answer:

           while (Num>=0) {

               System.out.println("enter a another number");

               Num = in.nextInt();

           }

Explanation:

The complete java code prompting a user to enter a number until a negative number is entered is given below:

import java.util.Scanner;

public class num6 {

public static void main (String [] args) {

Scanner in = new Scanner(System.in);

System.out.println("enter a number");

int Num = in.nextInt();

while (Num>=0) {

System.out.println("enter a another number");

Num = in.nextInt();

}

System.out.println("Done.");

return;

}

}

3 0
3 years ago
Add Try/Catch error checking To make sure that the user enters valid values in your program. To catch negative values passed to
ryzh [129]

Answer:

int main()

{

 cout<<"Enter the size of array\n";

 int n;

 try{

 cin>>n;//get size of array

 if (n > 0){

 List list;//make object of list class

 try{

     list.init(n);//initialize the list

     list.fillData();//fill the data

     list.print();//print the data

     list.sortData();//sort the  data

     cout<<"\n--- After sorting the data---\n";

     list.print();//print the data

     cout<<"Enter the element to search\n";

     int x;

     cin>>x;//get element to search

     list.searchElement(x);//call the search function

 }

 catch (std::bad_alloc){

   cout<<"Sorry, could not allocate memory for list object.";

 }

 }else{

   throw('Negative Number detected');

 }

 }

 catch (int n){

   cout<<"The number should be a positive integer.";

 }

   return 0;

}

Explanation:

The try and catch keywords come in pairs, as they are used to control exceptions in the C++ source code. The try keyword checks for error in the source code given the condition (if the n integer variable is greater than 0). If the condition is met, the code in the try code block runs otherwise the catch keyword catches the error of a negative number (if the n variable in less than 0).

4 0
3 years ago
Definition of powerpoint animation
saul85 [17]

Answer:

An powerpoint animation is an animation that uses powerpoint or another similar app like google slides to create a video, game, or movie.

but...

If you mean just in Microsoft Office it's a visual or sound effect that you can add to slides to make them more interesting.

Explanation:

3 0
2 years ago
Give a detailed example of how an app (that you use regularly)uses parameters. You must state the app's name and function, the p
sesenic [268]

Answer:

mobile calculator

Explanation:

The mobile calculator application is a mobile software on phones and other computer devices that returns the answer to a calculation given the operands and opcode specified by the user.

5 0
2 years ago
Colours can be contrasting if<br>​
abruzzese [7]

.....If the colors are from different segments of the color wheel.

3 0
2 years ago
Other questions:
  • The third wave of computing was characterized by the introduction of _____.
    10·1 answer
  • Select the answer that best describes the activity
    5·2 answers
  • Florida Highway Safety and Motor Vehicles reported blank of traffic fatalities were alcohol-related in Florida in 2009.​
    8·1 answer
  • What does it mean to search an index or the web? (DONT TAKE ANSWERS FROM THE INTERNET!)
    9·2 answers
  • Write a program that asks for the names of three runners and the time, in minutes (no seconds, etc.), it took each of them to fi
    7·1 answer
  • what type of machine is a ramp for wheelchairs? compound machine, mechanical, machine complex machine, simple machine
    15·2 answers
  • How can parents be health educators in family​
    13·1 answer
  • What output is generated by this for loop?
    6·1 answer
  • Which information can you apply to every page of your document with the page layout options?
    9·1 answer
  • What is the descriptor for a filter that warns or blocks you from potentially fraudulent or suspicious websites?.
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!