Friday, June 4, 2021

program check the number is perfect or not (POP) (140)

#include<iostream>

using namespace std;

int main()

{

int num,i,sum;

int mn,mx;

cout<<"please enter a number:";

cin>>num;

sum=0;

for(i=1; i<=num; i++)

{

if(num%i==0)

{

sum=sum+i;

cout<<i<<endl;

    }

}

cout<<"the sum is:"<<sum<<endl;

if(sum==num)

cout<<"the number is perfact:";

    else

    cout<<"the number is not perfact:";

    } 

No comments:

Post a Comment