Module Troubles

So I am very new to programming, I enjoy the problem solving aspect of, it but I can't fix all my problems because I barely know C++. So I am writing a program to simulate a math tutor it gives examples of basic arithmetic and then asks the user to do a few themselves. This was not a problem to write, but i am just learning modules so I am having a hard time getting them to communicate well and do exactly what I want. I have a main menu from which they choose which operation they would like to practice, this input is defined as option(i made it a global variable, I know this is frowned upon but its the best I can do with the experience I have) So the user inputs a number 1-5 in the main menu module, then the program goes to its selection module, which is 5 "if" statements 1-4 being the math operation, and 5 being exit. My problem is that no matter what the user input for option is, it always returns the first if statement.

void choice_logic(){
cout<<option<<endl;
if(option=1)
{
addition_module();
}
if(option=2)
{
subtraction_module();
}
if(option=3)
{
multiplication_module();
}
if(option=4)
{
division_module();
}
if(option=5)
{
(also having trouble getting it to exit, but its beside the point right now)
}
}

So i decided to do a little trouble shooting, and as you can see it displays the "option" variable at the beginning. I did this to see if it was bringing my variable over correctly; it does, whatever i type in the main menu to select is carried over correctly and displayed here and it still goes with the first if. always. I would appreciate any help, and if more context is needed let me know. Thanks.
This...
if(option = 1)
is the assignment operator, you meant to use the equality operator,
if(option == 1)

The first assigns option a value of 1, and then the statement evalutes to true, the second compares option to the value 1
Last edited on
Ah yes, I knew that! I guess that never really clicked for me before, but I understand now. Thanks. Also If a could get some help with that option 5. I want to make that link to my wrap up module and then close the program. I can link it to the wrap up module, but within all of my modules the "return 0;" that I use to end programs wont work. I get an error saying that the 'void' function is returning a value. So do I need to create this (wrap up)module in a different way to allow it to close my program?
Topic archived. No new replies allowed.