CS 355 - Systems Programming Lab 2 - Loops and functions
Objective: write a program that can iterate over a range of integers and make decisions based on various conditions.
- Write a C program fizzbuzz that prompts the user to enter an arbitrary integer:
Please enter an integer:
fizzbuzz prints each number between 0 and the entered number on a separate line as follows:
- If the number is multiple of 3, the program prints Fizz;
- If the number is multiple of 5, the program prints Buzz;
- If the number is multiples of both 3 and 5, the program prints FizzBuzz.
For example, if you enter 15, fizzbuzz would produce the following output:
FizzBuzz
1
2
Fizz
4
Buzz
Fizz
7
8
Fizz
Buzz
11
Fizz
13
14
FizzBuzz
fizzbuzz must include a loop to iterate over all integers in the given range.
fizzbuzz must include a function that takes a single integer as a parameter and produces the correct output for that integer.
Use the following input as test cases to verify the correctness of your code: -17, 0, 5, 15, 38.
- A single C source code file with your work.
- A screenshot (in PNG or JPG format) showing your program executing each of the three test cases on a Linux terminal.