Answer to Question #280219 in C++ for Jessa Flores

Question #280219

The FizzBuzz Game





by CodeChum Admin





Let's play a game of FizzBuzz! It works just like the popular childhood game "PopCorn", but with rules of math applied since math is fun, right?






Just print out "Fizz" when the given number is divisible by 3, "Buzz" when it's divisible by 5, and "FizzBuzz" when it's divisible by both 3 and 5!






Let the game begin!






1
Expert's answer
2021-12-16T04:46:24-0500
#include <iostream>
using namespace std;


int main(){
	int number;
	cout<<"Enter number: ";
	cin>>number;
	//If the number is only divisible by 3, print "Fizz"
	if(number%3==0){
		printf("Fizz\n");
	}
	//If the number is only divisible by 5, print "Buzz"
	if(number%5==0){
		printf("Buzz\n");
	}
	//If the number is divisible by both 3 and 5, print "FizzBuzz"
	if(number%3==0 && number%5==0){
		printf("FizzBuzz\n");
	}


	cin>>number;
	return 0;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog