#include <iostream>
#include <cmath>
usingnamespace std;
int main()
{
}
int isPerfect;
{
int n, sum = 0, f;
cout << "Enter a number: " << endl;
cin >> n;
while (n < 0)
{
cout << "Enter a number: " << endl;
cin >> n;
}
bool result;
for( f = 1; f <= n/2; f++)
if ( n % f == 0)
sum += f;
if ( sum == n)
result = true;
else
result = false;
if (result = true)
cout << "The number " << n << " is a perfect number." << endl;
elseif (result = false)
cout << "The number " << n << " is not a perfect number." << endl;
}
#include <iostream>
#include <cmath>
usingnamespace std;
int main()
{
}
int isPerfect
{
int n, sum = 0, f;
cout << "Enter a number: " << endl;
cin >> n;
while (n < 0)
{
cout << "Enter a number: " << endl;
cin >> n;
}
bool result;
for( f = 1; f <= n/2; f++)
{
if ( n % f == 0)
{
sum += f;
}
}
if ( sum == n)
{
result = true;
}
ifelse
{
result = false;
}
if (result = true)
{
cout << "The number " << n << " is a perfect number." << endl;
}
elseif (result = false)
{
cout << "The number " << n << " is not a perfect number." << endl;
}
}
if (result == true)
{
cout << "The number " << n << " is a perfect number." << endl;
}
else // just else, no condition
{
cout << "The number " << n << " is not a perfect number." << endl;
}