Академический Документы
Профессиональный Документы
Культура Документы
Follow the instructions in order to get maximum points. Please take your time and read the
instructions carefully.
Each question is worth 20 points. If you don't know how to solve one of the problems, just
skip it and go to the next one, first do the things you are sure that you know, later you can
come back and try the ones which you didn't know.
Open Dev C++. For each question make a new file. Save the files as Problem 1, Problem
2, etc.
Good luck!
Write a program that asks the user for their name then it greets them. After that it should
ask the user how they feel and respond like in the example below.
NOTE: the varaible needs to be of type string, not int.
EXAMPLE:
EXAMPLE:
Enter a number:12
Enter a number: 4
The number is divisible by 2.
PROBLEM 3 (20 POINTS)
• Make a program which will ask the user to enter a character. Use the switch function.
• Explain to the user what the program will do, print the following on the screen:
o Please choose a character.
Addition = +
Subtraction = -
Division = /
Multiplication = *
• If the character is „+“ the program should ask the user to enter 2 numbers and print
their sum.
• If the character is „-“ the program should ask the user to enter 2 numbers and print
their difference.
• If the character is „/“ the program should ask the user to enter 2 numbers and print
their ratio.
• If the character is „*“ the program should ask the user to enter 2 numbers and print
their product.
• If the user enters a wrong character print: „The character is wrong“.
EXAMPLE:
• Write a program that requires a user to enter a natural number n from the keypad.
• The program prints a sum of even numbers smaller or equal to n.
EXAMPLE:
• Write a program that requires a user to enter a number until the user guesses the
correct number.
• When the user enters a number which is higher than the required one, you should
print: „The number you entered is bigger than the one you are looking for. Please try
again.“ The user should then enter the number again. The process is repeated until
the user guesses the correct number.
• When the user enters a number which is smaller than the required one, you should
print: „The number you entered is smaller than the one you are looking for. Please try
again.“ The user should then enter the number again. The process is repeated until
the user guesses the correct number.
• When the user guesses the number print: „You win.“
• The number which the user needs to guess is 16.
EXAMPLE:
The number you entered is smaller than the one you are looking
for. Please try again.
25
The number you entered is bigger than the one you are looking
for. Please try again.
10
The number you entered is smaller than the one you are looking
for. Please try again.
16
You win.
When you finish all the requirements, save the files in one folder and save it as a .rar file,
then go to your Google Classroom account and upload the file to the „C++ Exam“
assignment.