Assignment 4
Assignment 4
Introduction to Computing
Assignment 4
Instructions
• Create separate file for each task. And name each file as task1.cpp, task2.cpp, task3.cpp ….
• Please follow the deadline. In case of late submission, marks will be deducted. On late submission of every
hour, 10% marks will be deducted.
• Submit assignment on LMS only in specified folder “Assignment 4 – Submission Folder”. No hard copy will be
accepted. Do not zip folder or submit folder. Only submit cpp files
• If plagiarism found, zero marks will be awarded. Consider this instruction as last warning, don’t ask for second
warning!
Question 1
Write a C++ program that asks a user to enter a positive number of integer type. Find the factorial of that number.
Note: 5! = 5 * 4 * 3 * 2 * 1 = 120 6! = 6 * 5 * 4 * 3 * 2 * 1 = 720
Question 2
Write a C++ program that asks a user to enter a number of integer type and checks whether the number is prime or not.
Note: A number that is only divisible by 1 or itself is known as prime number. 2, 3, 5, 7, 11, 13, 17 etc. are prime numbers.
Example
Test case 1:
Please enter a number: 63
63 is not a prime number.
Test case 2:
Please enter a number: 79
79 is a prime number.
Question 3
Write a program that asks a user to dial a mobile phone number (03xx-xxxxxxx). And to stop dialing, he shall press ‘#’. If
a user has dialed correct mobile number, display the message “Your call is being transferred to the respective dialed
number successfully”. If a user enters invalid number or incomplete number, then display the message “You have dialed
invalid number” or “You have dialed incomplete number”.
Example
Test case 1:
Please enter a mobile number: 0 3 2 1 8 0 0 0 7 6 5 #
Your call is being transferred to the respective dialed number successfully
Test case 2:
Please enter a mobile number: 0 3 2 1 8 0 6 5 #
You have dialed incomplete number
Test case 3:
Please enter a mobile number: 0 3 2 1 a
You have dialed invalid number