How can i use function as a recipe for any number from array

  c++, function

In void in, line if (hoanhao(a[i])). I got an error ‘hoanhao’ cannot be use as a func. I want to use hoan hao as a recipe so i can get result from arr

bool hoanhao(int a[], int n){//to get perfect number
    int sum = 0;
    for (int i=0;i<n;i++){
        if (n%i==0){
            sum+=i;
        }
    }
    if (sum==n){
        return true;
    }else{
        return false;
    }
}

void in(int a[], int n, bool hoanhao){
    for (int i=0;i<n;i++){
        if (hoanhao(a[i])){
            cout<<i;
        }
    }
}

Source: Windows Questions C++

LEAVE A COMMENT