Question: Using c++ Exercise 2: Perfect numbers Write a program to ask the user for an integer n and then prints out if n is a
Exercise 2: Perfect numbers Write a program to ask the user for an integer n and then prints out if n is a perfect number Use a return-value function, to be called perfect (..) to test whether a given number is perfect or not. The prototype statement for this function is bool perfect (int); Create another function: bool DivisibleBy (int n, int i) check if the number n is divisible by an integer i. Note: Perfect number, a positive integer that is equal to the sum of its proper divisors except the 1+2+3, and 1,2,3 are the divisors of 6) number itself (e.g., 6 is perfect since 6- Sample input/output: t: 6 Enter a number to check if it is a perfect or no 6 is divisible by 1 6 is divisible by 2 6 is divisible by 3 6 is a perfect number Enter a number to check if it is a perfect or not: 24 24 is divisible by 1 24 is divisible by 2 24 is divisible by 3 24 is divisible by 4 24 is divisible by 6 24 is divisible by 8 24 is divisible by 12 24 is NOT a perfect number
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
