9: perfect.cpp) A number is called perfect if the sum of its divisors is equal to the original number. A number is called deficient if the sum of its divisors is less than the original number. A number is called abundant if the sum of its divisors is more than the original number. Write a program that answers the following questions: What numbers below 5000 are perfect? What odd numbers below 5000 are abundant? What are the relative proportions of deficient, abundant, and perfect numbers? 5000 should be in a global constant.

C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN:9781337102087
Author:D. S. Malik
Publisher:D. S. Malik
Chapter8: Arrays And Strings
Section: Chapter Questions
Problem 21PE
icon
Related questions
Question
100%

Please use C++ language and only use the library <iostream>. Thank you!

Perfect.cpp: deficient, abundant and perfect numbers
#include <iostream>
using namespace std;
const int LIMIT=5000;
int sumofDivisors(int);
int main()
{
int num, divisorSum;
Declare three running totals and
set them to zero here.
for(num-1;num<=LIMIT; num++)
{
divisorSum=sumofDivisors(num);
if(divisorSum<num)
Increment them here.
Print relative proportions here.
return o;
}
Finally, set up three running totals to count the deficient, perfect, and abundant
numbers so you can print the relative proportions of each after the loop. You will never
need more than one for loop in the main program.
Transcribed Image Text:Perfect.cpp: deficient, abundant and perfect numbers #include <iostream> using namespace std; const int LIMIT=5000; int sumofDivisors(int); int main() { int num, divisorSum; Declare three running totals and set them to zero here. for(num-1;num<=LIMIT; num++) { divisorSum=sumofDivisors(num); if(divisorSum<num) Increment them here. Print relative proportions here. return o; } Finally, set up three running totals to count the deficient, perfect, and abundant numbers so you can print the relative proportions of each after the loop. You will never need more than one for loop in the main program.
9: perfect.cpp) A number is called perfect if the sum of
its divisors is equal to the original number. A number is
called deficient if the sum of its divisors is less than the
original number. A number is called abundant if the sum of
its divisors is more than the original number. Write a
program that answers the following questions: What
numbers below 5000 are perfect? What odd numbers below
5000 are abundant? What are the relative proportions of
deficient, abundant, and perfect numbers? 5000 should be
in a global constant.
Transcribed Image Text:9: perfect.cpp) A number is called perfect if the sum of its divisors is equal to the original number. A number is called deficient if the sum of its divisors is less than the original number. A number is called abundant if the sum of its divisors is more than the original number. Write a program that answers the following questions: What numbers below 5000 are perfect? What odd numbers below 5000 are abundant? What are the relative proportions of deficient, abundant, and perfect numbers? 5000 should be in a global constant.
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps with 1 images

Blurred answer
Knowledge Booster
Introduction to Coding
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning
C++ for Engineers and Scientists
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr