Write a program to check whether a number given by the user is prime, armstrong, perfect number or not using functions correctly. (Using C++) For this program, you should create three functions named isPrime, isArmstrong, isPerfect.
2) Write a program to check whether a number given by the user is prime,
armstrong, perfect number or not using functions correctly. (Using C++) For this program, you should create three functions named isPrime, isArmstrong, isPerfect.
Hint:
a) A prime number is a natural number greater than 1, which is only divisible by 1 and itself.
b) An integer number is called Armstrong number if sum of the cubes of its digits is equal to the number itself. For example: 370 is an armstrong number because:
370=3*3*3+7*7*7+0*0*0 =27+343+0 =370
c) A perfect number is a positive integer which is equal to the sum of its proper positive divisors. For example: 6 is the first perfect number. Proper divisors of 6 are 1, 2, 3. Sum of its proper divisors = 1 + 2 + 3 = 6. Hence 6 is a perfect number.


Trending now
This is a popular solution!
Step by step
Solved in 2 steps









