Question: Q 5 . Write a program Prime.cpp that prompts for user input of a positive integer and displays whether the input number is a prime
Q Write a program Prime.cpp that prompts for user input of a positive integer and displays whether the input
number is a prime number of not. A number is a prime number if it is divisible by and itself only. Note that
is not a prime number.
Sample result :
Input a positive integer:
is a prime number
Sample result :
Input a positive integer:
is not a prime number
Hint: All numbers, no matter prime or not, are divisible by and itself. Except and itself, a prime number
does not has other factor.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
