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.

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
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.
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education