Question: Write a C++ program, named perfect.cc that displays all the perfect numbers that is between 0 and 10000 exclusive. A perfect number is such an

 Write a C++ program, named perfect.cc that displays all the perfect

Write a C++ program, named perfect.cc that displays all the perfect numbers that is between 0 and 10000 exclusive. A perfect number is such an integer: the sum of all its positive divisors (excludes the number itself) equals to the number itself. For example, number 6 is a perfect number. Its divisors are 1, 2, and 3. The sum of these divisors 1 + 2 + 3 equals to the number 6 itself. A user-defined function is required in this program: The function "IsPerfect" will determine if the number is perfect or not. The input (via function parameter) to this function is an integer number. The function returns true if the number if perfect, and false otherwise. In the main function, one needs to write a for loop that loops through all the numbers from 1 to 10000. On each loop iteration, the function passes one value to the "IsPefect" function to check if that number is perfect. If yes, display that value. Here are some suggestions for developing your program: Develop your program in steps: First, write a simple main function that only contains a call to function "IsPerfect". Pass to the function a number chosen between 1 and 10000. Check to see if "IsPerfect" function returns the correct result. a. Use out statements to debug and make sure the function works correctly. Write the for loop structure in the main function to check values between 1 and 10000, one by one. Finalize the program with any other required output

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!