#define n 9999
bool IsPerfect(int n);
main()
{
int j;
for(j = 1; j <=n; j++)
{
if(IsPerfect(n) == TRUE)
{
printf("%d", IsPerfect(n));
}
}
}
bool IsPerfect(int n)
{
int total, i;
total = 0;
for(i=1; i <= n; i++)
{
if(n % i == 0)
{
total += i;
}
if(total == i)
{
return(TRUE);
}
else
{
return(FALSE);
}
}
}
Ok so I get a syntax error on the two lines that have "bool IsPerfect(int n)" and I have no idea why.....help?
2007-10-17
16:16:22
·
5 answers
·
asked by
rcossy1023
2
in
Computers & Internet
➔ Programming & Design
Ok so I made it "bool IsPerfect()" but now all i get is 0....probably 9999 of them....whats wrong with my math in the IsPerfect function??? too many ifs?
2007-10-17
17:08:21 ·
update #1