dorisspears45831 dorisspears45831
  • 02-09-2019
  • Computers and Technology
contestada

Return true if the given non-negative number is a multiple of 3 or 5, but not both. Use the % "mod" operator.

Respuesta :

asadashraf7788
asadashraf7788 asadashraf7788
  • 05-09-2019

the following C++ function will return true if the given non - negative number is multiple of 5 or 3 else it will return false.

bool function( int x ){

// variable to check if it is multiple of both or not

int number =0;

if(3%x == 0){

number++;

}

if(5%x == 0){

number++;

}

// Now returning by deciding

if( number <=1)

return true;

else

return false

}

Answer Link

Otras preguntas

How do you prepare for a group discussion?
physical geography, also known as
Choose the comparison operator that will create a true statement in scratch. 45 is equal to 50 45 is greater than 50 45 is less than 50 45 plus 50
Where did the Japanese attack in Hawaii?
A car requires 4 quarts of oil, but only liters are available. When the engine is filled to capacity with oil, how much, in liters, will be left? (1 qt = 0.946
Your goal is to navigate a robot out of a maze. The robot starts in the center of the maze facing north. You can turn the robot to face north, east, south, or w
A lighthouse sits at the wdge of a cliff. a ship at sea level is 550 m from the base of the cliff. the angle of elevation from sea level to the base of the ligh
What to do in 49 days after death?
Find the simple interest on a $500 investment made for 2 yr at an interest rate of 8%/year. What is the accumulated amount?
Why can't 1 be the base of an exponential equation?