hi there, I have started to go through the tourtorials so far i have got up to the case section and decided to try and make a simple form of calculator i suspose you could call it. To see if i could still remember the stuff from the earlier tutorials. so far i have written the coding below but when i try to compile i get this error
" line 26 error: expected initializer before "int"
the code is a combonation of the tutorial and what i made my self. as far as i know i could be a millons miles off the actual code i need. any help would be greatly accepted so that i know how to avoid the error in the future as well.Code:#include <iostream> using namespace std; int input; int mult ( int x, int y); int main() { int x; int y; int main(); { cout<<"enter two numbers (sperated by a space): "; cin>> x >> y; cin.ignore (); cout<<"the answer is "<< mult ( x, y ) <<"\n"; cin.get(); } int mult ( int x, int y ) int input; cout<<"1. multiply\n"; cout<<"2. devide\n"; cout<<"3. subtract\n"; cout<<"4. add\n"; cout<<"Selection: "; cin>>input; switch ( input ) { case 1: { return x * y; } break; case 2: { return x / y; } break; case 3: { return x - y; } break; case 4: { return x + y; } break; default: cout<<"Error, bad input, quitting\n"; break; } }



LinkBack URL
About LinkBacks


