You are on page 1of 1

EXERCISES:

if-else statements and simple functions



1. Write a program in C that prompts the user to enter a number. If the number is between
1 to 12, the program outputs the name of the month that corresponds with the number
(E.g. 1 will produce “January”). If any other number is entered, an appropriate error
message is displayed. Name your file months.cpp.

1: Plantain chips - $400
2: Fried rice - $600
3: Chowmein - $700
4: Stir-fried vegetables - $500
5: Pot-roast chicken + fried rice/chowmein - $1200
6: Fried chicken + fried rice/chowmein - $1300
7: Fresh fruit punch - $300


2. Consider the menu above. Write a program in C that takes a number input from the user
and displays the corresponding item description and price to user. Display an error
message if the user enters an invalid option. Name your file menu.cpp

3. Write a function called findSquare(int num) that takes an integer argument and returns
the square of the given number. Print the number and its square to the screen. Name
your file square.cpp

4. Write a function called isEven(int num) that takes an integer argument and returns true
if the number entered is even and false if it is not. Print appropriate messages to inform
the user if they have entered an even or odd number. Name your file even.cpp

You might also like