Check Number Either it is Perfect Or Not Using C++
========================================================================
#include<iostream>
using namespace std;
main()
{
int i=1;
int num;
int count=0;
cout<<"Enter Any Number To check\n";
cin>>num;
while(i<num)
{
if(num%i==0)
{
count=count+i;
}
i++;
}
if(count==num)
{
cout<<num<<" Is a Perfect Number\n";
}
else
cout<<num<<" Is Not A Perfect Number\n";
}
=======================================================================
0 comments:
Post a Comment