Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   General Computer Support (http://www.velocityreviews.com/forums/f44-general-computer-support.html)
-   -   C++ Program won't compile (http://www.velocityreviews.com/forums/t745101-c-program-wont-compile.html)

ian5142 03-14-2011 05:41 PM

C++ Program won't compile
 
Hi
I am learning C++ and I tried to make a little program that will tell me what 2 numbers are between (see code) and do 4 functions with them (+, -, *, /). I can not get the program to return one of my predetermined phrases under int a or int b, back to my cout under int main. I want to have an int a and b like this. What am I missing?

Code :
--------------------------------------------------------------------------------------------------------------------------------------

#include <iostream>

using namespace std;

int mult ( int numnber1, int number2 );

int divi ( int number1, int number2 );

int subt ( int number1, int number2 );

int addi ( int number1, int number2 );

int a ( int number1, char p1, char p2, char p3, char p4, char p5 );

int b ( int number2, char p1, char p2, char p3, char p4, char p5 );



int main()
{
char p1 [] = "equal to 100";
char p2 [] = "greater than or equal to 50 but less than 100";
char p3 [] = "greater than 100 but less than 1000";
char p4 [] = "greater than or equal to 1000";
char p5 [] = "less than 50";
int number1, number2;

cout<<"Please enter 2 numbers separated by a space (largest number first): ";
cin>> number1 >> number2;
cin.ignore();



cout<< "The product of "<< number1 <<" and "<< number2 <<" is "<< mult ( number1, number2 ) <<"\n";

cout<< "The quotient of "<< number1 <<" and "<< number2 <<" is "<< divi ( number1, number2 ) <<"\n";

cout<< "The difference of "<< number1 <<" and "<< number2 <<" is "<< subt ( number1, number2 ) <<"\n";

cout<< "The sum of "<< number1 <<" and "<< number2 <<" is "<< addi ( number1, number2 ) <<"\n";

cout<< " "<< number1 <<" is "<< int a ( int number1, char p1, char p2, char p3, char p4, char p5 ) <<"\n";

cout<< " "<< number2 <<" is "<< int b ( int number2, char p1, char p2, char p3, char p4, char p5 ) <<"\n";
}
int mult ( int number1, int number2 )
{
return number1 * number2;
}

int divi ( int number1, int number2 )
{
return number1 / number2;
}

int subt ( int number1, int number2 )
{
return number1 - number2;
}

int addi ( int number1, int number2 )
{
return number1 + number2;
}

int a ( int number1, char p1, char p2, char p3, char p4, char p5 )
{

if ( number1 == 100) {
return p1;
}
else if ( ( number1 < 100 ) && ( number1 >= 50 )) {
return p2;
}
else if ( ( number1 > 100 ) && ( number1 < 1000) ) {
return p3;
}
else if ( number1 >= 1000 ) {
return p4;
}
else if ( number1 < 50) {
return p5;
}
}

int b ( int number2, char p1, char p2, char p3, char p4, char p5 )
{

if ( number2 == 100) {
return p1;
}
else if ( ( number2 < 100 ) && ( number2 >= 50 )) {
return p2;
}
else if ( ( number2 > 100 ) && ( number2 < 1000) ) {
return p3;
}
else if ( number2 >= 1000 ) {
return p4;
}
else if ( number2 < 50) {
return p5;
}
}

---------------------------------------------------------------------------------------------------------------------------------

I got these warnings and errors:

L42 - Error: expected primary-expression before 'int'
L42 - Error: expected ' ; ' before 'int'
L44 - Error: expected primary-expression before 'int'
L44 - Error: expected ' ; ' before 'int'
L21 - Warning: unused variable 'p1'
L22 - Warning: unused variable 'p2'
L23 - Warning: unused variable 'p3'
L24 - Warning: unused variable 'p4'
L25 - Warning: unused variable 'p5'

What am I doing wrong?


All times are GMT. The time now is 10:45 AM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.