0% found this document useful (0 votes)
17 views

Assignment 4

The document provides instructions for an assignment with 3 questions. It asks students to write C++ programs that find the factorial of a number, check if a number is prime, and validate a phone number input. Programs must be submitted individually by the deadline to receive full marks.

Uploaded by

Siddique Rana
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
17 views

Assignment 4

The document provides instructions for an assignment with 3 questions. It asks students to write C++ programs that find the factorial of a number, check if a number is prime, and validate a phone number input. Programs must be submitted individually by the deadline to receive full marks.

Uploaded by

Siddique Rana
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

Deadline: Dec 03, 2019 09:00 p.m.

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

Please enter a positive number: 5


The factorial of 5 is 120

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

You might also like