The following code is to become a program that will return a given number as perfect, abundant, or deficient.
Code:
#include <iostream>
#include <fstream>
#include <cmath>
using namespace std;
//Prototypes
void header();
char FindSum();
// Main program.
int main()
{
int a;
cout << header;
cout << "Please enter a positive integer greater than 1 to continue, or enter a number less than or equal to 0 to quit: ";
cin >> a;
if (a <= 0)
return 0;
else if (a == 1)
{
cout << "Invalid number. Please enter a valid number: ";
cin >> a;
}
while (a > 1)
{
cout << "Please enter another integer to caluclate, or enter 0 or a negative number to quit: ";
cin >> a;
cout << FindSum(a, (a-1));
if (a <= 0)
return 0;
else if (a == 1)
{
cout << "Invalid number. Please enter a valid number: ";
cin >> a;
}
}
return 0;
}
// Displays header as seen above
void Header()
{
cout << "Trey Brumley" << endl;
cout << "CMPS 1043-101" << endl;
cout << "November 19, 2012" << endl;
cout << "Program 4" << endl;
cout << "=================" << endl;
return;
}
// Returns single character
char FindSum(int x, int y, int sum = 0)
{
int z;
char Class;
for (y > 0; y = (x - 1); y--)
{
z = x / y;
if (x % y == 0)
sum += z;
}
if (sum == x)
Class = 'P';
else if (sum > x)
Class = 'A';
else
Class = 'D';
return Class;
}
However, every time I try to debug it on Visual Studio, I get the following error messages:
Code:
1>c:\users\trey\documents\visual studio 2010\projects\program 4\program 4\main.cpp(35): error C2660: 'FindSum' : function does not take 2 arguments
1>c:\users\trey\documents\visual studio 2010\projects\program 4\program 4\main.cpp(64): warning C4552: '>' : operator has no effect; expected operator with side-effect
I don't know where the problem is because it's not giving me any red lines to show where I'm going wrong. Help please!