University of Management and Technology
School of Science and Technology
Assignment
NOTE:
• PLAGIARISED ASSIGNMENT EITHER FROM CLASSMATES OR INTERNET
WILL BE MARKED STRAIGHT ZERO.
• NO ASSIGNMENT WILL BE ACCEPTED AFTER DEADLINE.
• THE ASSIGMENT IS TO BE SUBMITTED VIA LMS.
• MAKE SURE YOU SEND IT IN A .cpp FILE.
• EACH QUESTION CONTAIN 5 MARKS.
Question 1 : Temperature Conversion
Write a program to convert temperatures between Fahrenheit and Celsius.
• Create two functions:
o float fahrenheitToCelsius(float fahrenheit)
o float celsiusToFahrenheit(float celsius)
• In the main() function, ask the user to enter a temperature and specify the
conversion type.
Question 2 : Factorial Calculator
Write a program to compute the factorial of a number.
• Create a function int factorial(int n) that takes an integer n as input and returns
its factorial.
• In the main() function, prompt the user for a number and display the factorial.
Factorial concept:
[Link]
Question 3 : Prime Number Checker
Write a program to check if a number is prime.
• Create a function bool isPrime(int number) that returns true if the number is
prime, otherwise returns false.
• In the main() function, take input from the user and display whether the
number is prime.
Question 4 : Simple Calculator
Write a program to create a simple calculator. With a menu using switch.
• Create functions for addition, subtraction, multiplication, and division:
o float add(float a, float b)
o float subtract(float a, float b)
o float multiply(float a, float b)
o float divide(float a, float b)
• In the main() function, ask the user to enter two numbers and the operation
they want to perform.
Bonus Question: Palindrome Number Checker
Write a program to check if a number is a palindrome.
• Create a function bool isPalindrome(int number) that checks whether the
number is the same when read forward and backward.
• In the main() function, take a number as input and display the result.
Palindrome concept:
[Link]
Hint:
[Link]