CS 355 - Systems Programming Lab 1 - Loops, condition, 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.
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 three test cases to verify the correctness of your code by entering the following numbers at the fizzbuzz prompt: -1, 5, 28.
- 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.