I have a lab to create a loop to determine the positive divisors of an interger and then determine if the interger is a perfect,deficient, etc. I am having trouble determining how to write the statement to determine the divisors of the numbers. I believe the % operator is used. Just not sure. Help!!
tonja1196
0
Newbie Poster
Recommended Answers
Jump to PostGreetings,
Well, you're right on. Finding the divisor of a positive number can be easily found using the modulus operator, %. The modulus operator works on integers (and integer expressions) and yields the remainder when the first operand is divided by the second. In C++, the modulus operator is …
Jump to Post>what do I need to do to show the total of the divisors?
Keep a running total. In StackOverflow's example, look at divisorSum that he neglected to declare. That's the general idea.
All 5 Replies
Stack Overflow
8
Junior Poster
tonja1196
0
Newbie Poster
tonja1196
0
Newbie Poster
Narue
5,707
Bad Cop
Team Colleague
tonja1196
0
Newbie Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.