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.
Addition of Two Numbers
Adding two numbers in programming is essentially the same as adding two numbers in general arithmetic. A significant difference is that in programming, you need to pay attention to the data type of the variable that will hold the sum of two numbers.
C++
C++ is a general-purpose hybrid language, which supports both OOPs and procedural language designed and developed by Bjarne Stroustrup. It began in 1979 as “C with Classes” at Bell Labs and first appeared in the year 1985 as C++. It is the superset of C programming language, because it uses most of the C code syntax. Due to its hybrid functionality, it used to develop embedded systems, operating systems, web browser, GUI and video games.
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.](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2F3f71a40a-4cff-4959-8946-a68dc332c184%2F53b8b52e-832b-4d76-a8e3-27c8a0726d61%2Fhum8vxk_processed.jpeg&w=3840&q=75)
![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.](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2F3f71a40a-4cff-4959-8946-a68dc332c184%2F53b8b52e-832b-4d76-a8e3-27c8a0726d61%2Fpw5bw3_processed.jpeg&w=3840&q=75)
![](/static/compass_v2/shared-icons/check-mark.png)
Trending now
This is a popular solution!
Step by step
Solved in 2 steps with 1 images
![Blurred answer](/static/compass_v2/solution-images/blurred-answer.jpg)
![C++ Programming: From Problem Analysis to Program…](https://www.bartleby.com/isbn_cover_images/9781337102087/9781337102087_smallCoverImage.gif)
![C++ for Engineers and Scientists](https://www.bartleby.com/isbn_cover_images/9781133187844/9781133187844_smallCoverImage.gif)
![C++ Programming: From Problem Analysis to Program…](https://www.bartleby.com/isbn_cover_images/9781337102087/9781337102087_smallCoverImage.gif)
![C++ for Engineers and Scientists](https://www.bartleby.com/isbn_cover_images/9781133187844/9781133187844_smallCoverImage.gif)