How to check whether a given number is perfect or not in C++ Program

CWC
0 Min Read

How to check whether a given number is perfect or not in C++ Program

# include 
#include
# include 
using namespace std;
int main( )
{
int i,n,s=0;
cout<<"enter the number"; cin>>n;
for(i=1;i<n/2;i++)if(n%i==0) s+=i;
if(s==n) cout<<"the number is perfect no";
else cout<<"the number is not perfect ";
return 0;
}
Share This Article
Leave a comment

Leave a Reply

Your email address will not be published. Required fields are marked *

English
Exit mobile version