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

Of the 75 boys in the 7th grade class, 25 participate in at least one sport. Of the 120 girls in the 7th grade class, 30 participate in at least one sport. Does
Which statements describe constructive forces? Check all that apply. A volcano erupts. A river deposits gravel at a bend. Tree roots crack a boulder. A glacier
Explain the difference between the associative addition and the commutative addition
How did our country go from compromise to war?
Pinky's science fair project in junior high focused on an observation that the Crickets outside her window chirp less frequently when the temperature was colder
Simplify: (XY3Z4)4 A.xy3z16 B.xy3z8 C.x4y12z16 D.x5y7z8
lab report for physical and chemical changes??!
Tor F Science and technology are mutually beneficial.
If a system is maintained at a pressure of 2 psi of vacuum, what is the pressure in psia (lbs per square inch absolute)
What is the value of y? Find the following angle measures. m