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

I'm not sure ic I just leave like since I can't combine
If a flea can jump straight up to a height of 0.550 m , what is its initial speed as it leaves the ground?
Need help asap please!!!
Which word comes after disconnect in alphabetical order
Perform the indicated operation. (5 - 2i 2) 2
Which word correctly completes this sentence? La señorita Ana _______ sabiduría. es tienes soy tiene
What is the value stored at x, given the statements: int x; x = 3 / static_cast(4.5 + 6.4);?
Which of the following is the correct minimum coverage that you must have for Property Damage Liability? $2,500 $5,000 $10,000 $7,500
The first three steps for solving the quadratic equation by completing the square are shown. Fill in the missing number in the last step
The function below shows the number of car owners f(t), in thousands, in a city in different years t: f(t) = 0.25t2 − 0.5t + 3.5 The average rate of change of