Create a function that takes a number as an argument and returns "Fizz", "Buzz" or "FizzBuzz" • • • If the number is a multiple of 3 the output should be "Fizz" If the number given is a multiple of 5, the output should be "Buzz" If the number given is a multiple of both 3 and 5, the output should be "FizzBuzz" • If the number is not a multiple of either 3 or 5, the number should be output on its own as shown in the examples below. • The output should always be a string even if it is not a multiple of 3 or 5. Examples fizz buzz (3) ➡ "Fizz" fizz buzz (5) ➡ "Buzz" fizz buzz (15) → "FizzBuzz" fizz buzz (4) - "4" (Ctrl)

C++ for Engineers and Scientists
4th Edition
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Bronson, Gary J.
Chapter6: Modularity Using Functions
Section6.2: Returning A Single Value
Problem 13E
icon
Related questions
Question
Create a function that takes a number as an argument and
returns "Fizz", "Buzz" or "FizzBuzz"
If the number is a multiple of 3 the output should be "Fizz"
• If the number given is a multiple of 5, the output should be "Buzz"
If the number given is a multiple of both 3 and 5, the output should
be "FizzBuzz"
●
•
If the number is not a multiple of either 3 or 5, the number should be output
on its own as shown in the examples below.
•
The output should always be a string even if it is not a multiple of 3 or 5.
Examples
fizz buzz (3) → "Fizz"
fizz buzz (5) → "Buzz"
fizz buzz (15) ➡ "FizzBuzz"
fizz buzz (4) <-> "4"
(Ctrl)
Transcribed Image Text:Create a function that takes a number as an argument and returns "Fizz", "Buzz" or "FizzBuzz" If the number is a multiple of 3 the output should be "Fizz" • If the number given is a multiple of 5, the output should be "Buzz" If the number given is a multiple of both 3 and 5, the output should be "FizzBuzz" ● • If the number is not a multiple of either 3 or 5, the number should be output on its own as shown in the examples below. • The output should always be a string even if it is not a multiple of 3 or 5. Examples fizz buzz (3) → "Fizz" fizz buzz (5) → "Buzz" fizz buzz (15) ➡ "FizzBuzz" fizz buzz (4) <-> "4" (Ctrl)
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps with 1 images

Blurred answer
Knowledge Booster
Variables
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ for Engineers and Scientists
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning