C++ task about perfect number
The task Creat a program that imports 10 natural numbers from the keyboard and determines only the sum of the perfect numbers #include <iostream> using namespace std; int main() { int number, counter=1, sum=0, y=0, temp; for (int i=0; i<10; i++) cin>>number; // it is for importing 10 numbers temp=number; if(number<=0){ cout<<"error"; return 0; } while (counter<temp){ // if you want know if((temp%counter)==0) // your number is sum+=counter; // perfect or not you must counter++; // divide it all the numbers that } // smaller than it if (number==sum){ y=y+number; } else { break; } } cout<<y; return 0; } The problem is that I don't know where is my mistake