error expected initializer before void line 7

#include <iostream>
#include <cmath>
using namespace std;
// ***********************************************************************
void showmenu();
void cube(double userinput)
void inverse(double userinput)
void log(double userinput)
void absvalue(double userinput)
void squareroot(double userinput)


// ***********************************************************************

int main(void)
{

char menuoptions;
double userinput;

do
{
showmenu();
cin>>menuoptions;

// ***********************************************************************
while (menuoptions !== '1','2','3','4','5','0')
{
cout << "Please select a menu item (0-5): ";
cin >> menuoptions;
}

if ( menuoptions != '0')
{
cout << "Enter a non negative decimal number:";
cin >> userinput;

switch (menuopitons)
{
case 1: SquareRoot(userinput);
break;
case 2: AbsValue(userinput);
break;
case 3: Log(userinput);
break;
case 4: Inverse(userinput);
break;
case 5: Cubed(userinput);
}
if ( menuoptions != '1')
{
cout << "Enter a non negative decimal number:";
cin >> userinput;

switch (menuopitons)
{
case 1: SquareRoot(userinput);
break;
case 2: AbsValue(userinput);
break;
case 3: Log(userinput);
break;
case 4: Inverse(userinput);
break;
case 5: Cubed(userinput);
}
if ( menuoptions != '2')
{
cout << "Enter a non negative decimal number:";
cin >> userinput;

switch (menuopitons)
{
case 1: SquareRoot(userinput);
break;
case 2: AbsValue(userinput);
break;
case 3: Log(userinput);
break;
case 4: Inverse(userinput);
break;
case 5: Cubed(userinput);
}
if ( menuoptions != '3')
{
cout << "Enter a non negative decimal number:";
cin >> userinput;

switch (userinput)
{
case 1: SquareRoot(userinput);
break;
case 2: AbsValue(userinput);
break;
case 3: Log(userinput);
break;
case 4: Inverse(userinput);
break;
case 5: Cubed(userinput);
}
if ( menuoptions != '4')
{
cout << "Enter a non negative decimal number:";
cin >> userinput;

switch (userinput)
{
case 1: SquareRoot(userinput);
break;
case 2: AbsValue(userinput);
break;
case 3: Log(userinput);
break;
case 4: Inverse(userinput);
break;
case 5: Cubed(userinput);
}
if ( menuoptions != '5')
{
cout << "Enter a non negative decimal number:";
cin >> userinput;

switch (userinput)
{
case 1: SquareRoot(userinput);
break;
case 2: AbsValue(userinput);
break;
case 3: Log(userinput);
break;
case 4: Inverse(userinput);
break;
case 5: Cubed(userinput);
}
}
{
}
} while (menuoptions='0');


// ************************************************************************
return 0;
}
// *********************************************************************
// * Your functions that do the square root, absolute value, log, inverse, an
// * cube go here. // **********************************************************************
void showmenu()
{
cout<< "M E N U" <<endl;
cout<< "1 - Calculate Square Root" <<endl;
cout<< "2 - Calculate Cube" <<endl;
cout<< "3 - Calculate Natural Logarithm" <<endl;
cout<< "4 - Calculate Inverse" <<endl;
cout<< "5 - Absolute Value" <<endl;
cout<< "0 - Exit Program" <<endl;
cout<< "Enter Menu Option ";
}

void SquareRoot(double userinput)
{
cout << "The Square Root of"<<userinput<<"is"
<< (sqrt(userinput)) << endl;
}
void AbsValue(double userinput)
{
cout << "The Absolute Value of" << userinput<<"is"
<< (fabs(userinput) << endl;
}
void Log(double userinput)
{
cout << "The Natural Log of" << userinput<<"is"
<< (log(useriniput)) << endl;
}
void Inverse(double userinput)
{
cout << "The Inverse of" << UserEntry<<"is"
<< (1.0/userinput) << endl;
}
void Cubed(double userinput)
{
cout << "The cube of" << userinput<<"is"
<< (pow(userinput,3)) << endl;





It looks like your missing a bunch of semi-colons.

In future please be sure to use code tags when posting code and ask your question in the body of the post.

Do I need semicolons after
void cube(double userinput)
There are a number of issues in your code.

1. missing semicolons, yes you need one at the end of the declaration
void cube(double userinput);
2. Capitalization errors: AbsValue and absvalue are different names in C++
3. Spelling errors (menuoptions is misspelled many times)
4. You need to change the name of your function log, log is already defined in the math library.
5. There is a problem with the switch (menuoptions), menuoptions is defined as a char and the switch expects a numeric value. The char '5' is not the integer 5. You can instead write switch(menuoptions - '0') , this trick forces the conversion to an integer.
6. I have not really tried to understand the overall program but it is repetitive, which suggests there is probably something wrong with the structure and you should be able to simplify it with the correct loop.

The code tags mentioned by jlb are [code] before the code and /code between [] at the end of the code
Last edited on
Topic archived. No new replies allowed.