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

Who were the Britons fighting against in the middle ages?
How do u answer 3(x+2)=x-18
how do you simplify fractoins
Indicate true or false as to whether the following equation is quadratic 2x-4x+1=0
8k-1=15 ? Help I have a question were we have to work this out what do I do?
The square of a certain negative number is equal to 5 more than one half of the number what is the number
What is the value of the expression shown below when a=51, b=2, and c=17? 3(a\c)^2
a meter stick casts a shadow 1.4 m long at the same time a flagpole casts a shadow 7.7 m long. The triangle formed by the meterstick and its shadow is similar t
11. Consider the elements neon, bromine, and phosphorus. Which has five electrons in its 4p sublevel?
The square of a certain negative number is equal to 5 more than one half of the number what is the number