im have to a prefect number programme.
It requires to input a positive integer and print the prefect number less than that
Pleaseeee helppp
heres my code
If i input 100 it outputs 117 instead of 6 28 ...
Also it highlighted the line int main() and said function definition is not allowed here . what can i do . thank youuuuu
#include <iostream>
using namespace std;
int Perfect(int posInt){
int total=0;
for (int i=1; i<posInt; i++){
if (posInt%i==0){
total+=i;
return total;
}
}
int main(){
int input, i;
cin >> input;
if (input >0)
i=Perfect(input);
cout << i;
You seem to have mismatched braces. Check that every beginning brace '{' has a matching ending brace '}' and that you have the same number of beginning braces and ending braces.