Answer to Question #320060 in C++ for last chance

Question #320060

If the number is only divisible by 3, print "Fizz"


If the number is only divisible by 5, print "Buzz"


If the number is divisible by both 3 and 5, print "FizzBuzz"


If nothing is true in the previous conditions, skip the number

1
Expert's answer
2022-03-30T02:50:52-0400






#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