hello dears!
i have a question about my program i am suposed to make a program that calculates thea factors of a number and add them and see if the number is a perfect number. i made this program and it works fine but now i have to change this program to two funtion program first function, perftest(), shout take an integer an dreturn a bool value of true or false if the argument is or inst a perfect number.
the second function, factorPrint(), takes and integar and prints outthe factors of the argument in ascending order. so this is the function performs the output. and this function should be void.
Now i wrote my code like this, but i get error on the line where i called the both functions on the main() can anyone tell me what is wrogn with my program and what can i do to fix it as soon as possible.
#include <iostream>
using namespace std;
bool perfTest(int Num);
void factorPrint(int Num1);
int main()
{
int num;
int Fact;
do
{
cout << "How Many Numbers Would You Like To Test? ";
cin >> num;
}
while (num<=0);
for(int a=1; a<=num; a++)
{
cout << "Please enter a possible perfect number: ";
cin >> Fact;
if(perfTest()=true) factorPrint(); // This is what i called the functions
}
return 0;
}
// First Function ===============================
bool perfTest (int Num)
{
bool perfect;
int B=0;
for(int A=1; A!=Num; A++)
{
if(Num%A==0)
{
B+=A;
}
}
if(B==Num)perfect=true;
else
perfect=false;
return perfect;
}
//second function ===============================
void factorPrint(int Num1)
{
for(int A=1; A!=Num1; A++)
{
if(Num1%A==0)
{
cout << Num1 << ":" << A << " ";
}
}
return;
}