Im trying to get this program to work, but instead ive gotten at least 14 errors after i complied it...and idk why! its supposed to continuosly show the menu and run those functions based on user input.
a) '=' is the assignment operator. You're looking for '==', the comparison operator.
b) Your ifs are... nowhere. They should be in a function (in this case: in your main).
c) In getQuo (getPro): your passing double x (q), then redeclaring x (q). Drop the "double x" ("double q") either from the function body, or the function argument list. I suggest the latter, because it serves no point here.
[edit]
By the way, here's the "correct"/"standard" organization of a file:
1 2 3 4 5 6 7
// Includes
// Pre-declaration of functions
main() {
// Variable declaration
// Function calls
}
// Function definitions
// Includes
#include <iostream>
usingnamespace std;
// Function pre-declarations
double getSum(double num1, double num2);
// Main
int main() {
// Variable declaration
int a = 6;
int b = 7;
// Function calls
cout << "The sum of " << a << " and " << b << " equals: " << getSum(a,b) << "!" << endl;
return 1; // End of program.
}
// Function definition
double getSum(double num1, double num2) {
double sum;
sum = num1 + num2;
return sum
}
That's just one way to organize your files, but it's the standard [in the classroom]. Also, take a good look at where functions are called (in the main!) and how they are called.
1)how exactly would I get my menu to continuosly run while the program runs?
2)this program is for user input, so i dont think i can declare variables that are pre defined with numbers
3)and where would i put my "cin" so that the user can input and make these user-defined fucntions run
4)sorry, im just all confuzzled 0_o
do
{
cout<<"Operation Main Menu"<<endl;
cout<<"---------------------"<<endl;
cout<<"1.Addition "<<endl;
cout<<"2.Subtract "<<endl;
cout<<"3.Multiplication "<<endl;
cout<<"4.Division "<<endl;
cout<<"5.Exit "<<endl;
}
while (code<=5);
This loop will repeat as long as code has a value of 5 or less. Tell me, when exactly is code going to get a value above 5? This loop doesn't even change the value of code, so whatever value it has at the start, it will have forever. Looping round and round and round forever, waiting for something to change the value of code...
1. Use code < 5, obviously you want to be able to exit when it == 5.
2. Ask the user to input to code during the loop.
3. Test it, then write code in the loop to do the function specified by the user. ;)
This is how the program is supposed to be ran>>>>>
An Example: Operation Main Menu
====================
1. Addition
2. Subtract
3. Multiplication
4. Division
5. Exit
--------------------
Enter your operation code (1, 2, 3, 4 or 5): 1
*************************************************
Please enter two double numbers: 2.5 3.6
The sum is 6.10
*************************************************
Operation Main Menu
====================
1. Addition
2. Subtract
3. Multiplication
4. Division
5. Exit
--------------------
Enter your operation code (1, 2, 3, 4 or 5): 5
ive gotten my loop to stop, but i need it to continue after everytime the user gets the answer to each input. like stated above>>>>
#include <iostream>
using namespace std;