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

Why do geographers study human systems and human environment relationships?
what was Rutherford's contribution to our knowledge of atoms
List three examples of a primary economic activity?
What does ethical dimension mean
How would I write 21/8 as a mixed number?
Which religion in India combines the Muslim belief in one God with the Hindu belief in reincarnation?
The sum of two integers with different signs is 8. Give two possible integers that fit this description
What is the acceleration of a 10 kg mass pushed by a 5 N force?
there are two trains A and B. which are 30 kms apart. both the trains are moving towards each other with velocity of train A is 40 kms / hr velocity od train B
a recipe calls for cookies for 3 1/4 cups of. sugar.amy already puts in 3 1/9 cups.how many more cups does she nees t put in