help please

Joined
Nov 9, 2007
Messages
1
Reaction score
0
I get the error messages:

program17.cpp:108: error: ISO C++ forbids comparison between pointer and integer
program17.cpp:110: error: `num' was not declared in this scope
program17.cpp:110: warning: unused variable 'num'

the program is supposed to find the factors of the number, and output if it is a perfect number (factors add up to itself) or not.

here is my code, some insight would be appreciated.

#include <iostream>

using namespace std;

bool perfTest ( int NUM );
void factorPrint ( int NUM );

int main ()
{

int dig;
int num;
int counter = 0;

cout << "How many numbers should be tested?";
cin >> dig;

while ( dig < 1 )
{
cout << "How many numbers should be tested?";
cin >> dig;


while (counter != dig )
{
cout << "Please enter a possible perfect number: ";
cin >> num;

if ( perfTest == false)
{
cout << "NOT PERFECT" << endl;
counter++;
}
}
}

return 0;
}

bool perfTest ( int NUM )
{

int X;
int Y;
int TOT = 0;
int count;
bool rVal = false;

X = NUM;
count = X;

while ( count != 1 )
{

if ( NUM % count == 0 )
{
Y = NUM / count;

TOT = TOT + Y;
}

count--;
}

if ( TOT == NUM )
{
rVal = true;
}
return rVal;
}

void factorPrint ( int NUM )
{

int X;
int Y;
int count;

X = NUM;
count = 0;

while ( count != NUM )
{

if ( NUM % count == 0 )
{
Y = NUM / count;
}

count++;
}

if ( perfTest == 'true' )
{
cout << main(num) << ":" << Y << endl;;
}

return;

}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,073
Messages
2,570,539
Members
47,197
Latest member
NDTShavonn

Latest Threads

Top