Error unqualified id :( help me guys!

Here's the code...and I am getting an unqualified-id before '{' toke:

#include <iostream>
#include <cmath>
#include <string>

using namespace std;

// Function Prototypes ****************************************************

double returnResult (double numone, double numtwo);
double numone, numtwo;
double result;

// main function **********************************************************
int main ()
{
// All variable declarations go here at the top of the main function
cout << "Insert two numbers to be calculated: " << endl;
cin >> numone, numtwo;

result = returnResult(numone,numtwo);
cout << "The result it: " << result << "." <<endl;

// End of program statements
cout << "Please press enter once or twice to continue...";
cin.ignore().get(); // hold console window open
return 0; // successful termination
}
// end main() *************************************************************

// Function Implementations ***********************************************
double returnResult(double numone, double numtwo);

{
double returnResult(numone, numtwo);
returnResult = sqrt((pow(numone,3))+(pow(numtwo,3)));
return returnResult;
}


the error is pointed at the last "}"
hope you guys can help! thanks in advance!
Your function implementation has a semi-colon after first line - this is incorrect.

1
2
3
4
5
6
7
// Function Implementations ***********************************************
double returnResult(double numone, double numtwo);
{
   double returnResult(numone, numtwo);
   returnResult = sqrt((pow(numone,3))+(pow(numtwo,3)));
   return returnResult;
}


The first line in your function double returnResult(numone, numtwo) doesn't seem valid - I assume it should not even be there as an attempt at a recursive call as your returnResult function will then loop infinitely recursively.

The second line of your function is illegal as you are trying to treat the function name returnResult as a variable.

I assume therefore you want the following:

1
2
3
4
5
6
double returnResult(double numone, double numtwo)
{
   double retResult;
   retResult = sqrt((pow(numone,3))+(pow(numtwo,3)));
   return retResult;
}
Hey SIK I really appreciate your help!!

So after trying some stuff out, I was able to stop the error from happening but when I try to run it, I only get a return of 0....why is that??

here is the fixed version:

#include <iostream>
#include <cstdlib>
#include <cmath>
#include <string>

using namespace std;

// Function Prototypes ****************************************************

double returnResult (double numone, double numtwo);
double numone;
double numtwo;
double result;

// main function **********************************************************
int main ()
{
// All variable declarations go here at the top of the main function
cout << "Insert two numbers to be calculated: " << endl;
cin >> numone >> numtwo;

cout << endl << "The result is: " << result << "." <<endl;
result = returnResult(numone,numtwo);

// End of program statements
cout << "Please press enter once or twice to continue...";
cin.ignore().get(); // hold console window open
return EXIT_SUCCESS; // successful termination
}
// end main()

// Function Implementations ***********************************************
double returnResult(double numone, double numtwo)
{
double retResult;
retResult = sqrt((pow(numone,3))+(pow(numtwo,3)));
return retResult;
}
nice information.
You should swop the call to your returnResult function and the cout immediatley below around.

this way your variable [result] will get its value from the [returnResult] function before you output it to screen.

hope this helps.
Topic archived. No new replies allowed.