Also, when calling functions you simply write:
Code:
if(lesson == 1)
{
cout << "\n\n";
add();
}
rather than
Code:
if(lesson == 1)
{
cout << "\n\n";
void add();
}
If you do the second as you are doing it never calls the function.
--------------------------------------------------------------------
Also, not sure if you know, but you can have functions accept values and return values to simplify 'em and reduce code redundancy, which may result in more errors and difficulty changing your code at a later time. Of course this isn't necessary as your code should work just as well as is. Just providing an alternative example.
Ex:
Code:
#include <iostream>
using namespace std;
int add(int x, int y)
{
return x + y;
}
int sub(int x, int y)
{
return x - y;
}
int mult(int x, int y)
{
return x * y;
}
int div(int x, int y)
{
return x / y;
}
int main()
{
int lesson;
int x, y;
cout << "\n\n\n";
cout << " Welcome to Math Fun Lessons 1 - 4 \n\n\n";
cout << " Please select a lesson.\n\n";
cout << " 1. Addition \n";
cout << " 2. Subtraction \n";
cout << " 3. Multiplication \n";
cout << " 4. Division \n\n";
cout << " Lesson: ";
cin >> lesson;
cout << " Enter a number: ";
cin >> x;
cin.get();
cout << "\n\n Enter another number: ";
cin >> y;
cin.get();
cout << "\n\n\n";
if(lesson == 1)
{
cout << " " << x << " + " << y << " = " << add(x, y);
}
else if(lesson == 2)
{
cout << " " << x << " - " << y << " = " << sub(x, y);
}
else if(lesson == 3)
{
cout << " " << x << " * " << y << " = " << mult(x, y);
}
else if(lesson == 4)
{
cout << " " << x << " / " << y << " = " << div(x, y);
}
else
{
cout << " Invalid Syntax. Try again.\n\n";
}
}