![]() |
Why my program dont cout perfect number?
:
#include <iostream>why dont it cout perfect numbers, ? and in one forum for me advice to inicialise result, but i dont know which value add to it? |
Re: Why my program dont cout perfect number?
pls help!
|
Re: Why my program dont cout perfect number?
Quote:
|
Re: Why my program dont cout perfect number?
Don't bump threads. If people have an answer to offer, they will. If you don't get a reply, it means people can't help or are disinclined to.
In any event, the code; :
for (int i = 1; i < lim; i++) { |
Re: Why my program dont cout perfect number?
:
#include <iostream> |
Re: Why my program dont cout perfect number?
:
int Perfectnumber (int rob) {is wrong for a start the if sum == rob statement should be outside of the for loop, otherwise your exiting after the first iteration, you need that loop to finish calculating sum before you do this if check. :
for (int i = 1; i < lim; i++) {I don't understand why you need to check if n is a perfect number n amount of times. Perhaps you should look at your code and understand whats happening. |
Re: Why my program dont cout perfect number?
Quote:
The basic problem in your code is that you have code outside loops that need to be inside the loops, and other things inside loops that need to be outside. Hence the code runs incorrectly. That is enough information for you to fix your problem, if you just think about it a bit. |
| All times are GMT -5. The time now is 3:56 AM. |
Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC