error 3861 identifier not found

I'm making a programe to get perfect number.
and these are the code and i got the error message "error 3861 identifier not found"

Please help

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#include <iostream>
#include <iomanip>

using namespace std;

int main(){

	//Write a program that asks the user for input for two integer values:  startval, and endval.  The program will then find all Perfect Numbers that fall between startval and endval.  
	//A perfect number is a number equal to the sum of all its proper divisors (divisors smaller than the number) including 1.
	//The number 6 is the smallest perfect number; because it is the sum of its divisors 1, 2, and 3 (1+2+3 = 6). The next perfect number is  28 (28 = 1+2+4+7+14).

	int startVal, endVal, num = 0, inNum, possibleNum, sum;

	cout << "Enter starting integer : ";
	cin >> startVal;
	cout << "Enter ending integer : ";
	cin >> endVal;

	for(num = startVal ; num <= endVal ; num++){
		sum =0;
		for(inNum = 1 ; inNum < num ; inNum++){
			if(isAFactor(num, inNum))
				sum = sum + inNum;
			}
		if(sum == num){
					cout << num << " is a perfect number." << endl;
		}
	}
}
bool isAFactor (int num1,int num2){

	int numA = num1;
	int numB = num2;

	if(numA % numB == 0)
		return true;
	else
		return false;
}
move the body of isAFactor() to top of main()
move the body of isAFactor() to top of main()


This is kind of right. You don't want to move it to main (whether that be top, bottom or somewhere in between). You want to put it before main (I'm pretty sure that that is what you meant, but it seemed a little vague and easily misunderstood).

Another solution would be a function prototype:

http://cplusplus.com/doc/tutorial/functions2/

(it's in there, you just have to look for it)

Another thing is the use of a function in the if condition. I'm not sure whether that is "legal" or not.
I think the fuction in the if condition should be just fine.
Thank you guys It was really helpful!!!
Topic archived. No new replies allowed.