#include <iostream>
usingnamespace std;
int add(); // the add fucntion is prototyped
int subtract(); // the subtract fucntion is prototyped
int multiply(); // the multiply fucntion is prototyped
int divide(); // the divide fucntion is prototyped
int DisplayMenu(); // the menu fucntion is prototyped
int MenuSelection(); // the menu selector fucntion is prototyped
int main ()
{
int exitcode;
while(exitcode !='9')
{
DisplayMenu();
exitcode = MenuSelection();
break;
}
}
int add() //Add function is defined
{
int a;
int b;
int c;
cout<<"Enter the first number: "<<endl;
cin>>a;
cout<<"Enter the second number: "<<endl;
cin>>b;
c=a+b;
cout<<a<<"+"<<b<<"="<<c<<endl;
return 0;
}
int subtract() //Subtract function is defined
{
int a;
int b;
int c;
cout<<"Enter the first number: "<<endl;
cin>>a;
cout<<"Enter the second number: "<<endl;
cin>>b;
c=a-b;
cout<<a<<"-"<<b<<"="<<c<<endl;
return 0;
}
int multiply() //Multiply function is defined
{
int a;
int b;
int c;
cout<<"Enter the first number: "<<endl;
cin>>a;
cout<<"Enter the second number: "<<endl;
cin>>b;
c=a*b;
cout<<a<<"*"<<b<<"="<<c<<endl;
return 0;
}
int divide () //Divide function is defined
{
int a;
int b;
int c;
cout<<"Enter the first number: "<<endl;
cin>>a;
cout<<"Enter the second number: "<<endl;
cin>>b;
c=a/b;
cout<<a<<"/"<<b<<"="<<c<<endl;
return 0;
}
int DisplayMenu() //Display menu function is defined
{
cout<<" CALCULATOR "<<endl;
cout<<" 1. Add"<<endl;
cout<<" 2. Subtract"<<endl;
cout<<" 3. Multiply"<<endl;
cout<<" 4. Divide"<<endl;
cout<<" 9. Exit program"<<endl;
}
int MenuSelection()
{
int selection;
cout<<"Please enter a menu choice"<<endl;
switch(selection)
{
case'1': add();break;
case'2': subtract();break;
case'3': multiply();";break;
case '4': divide();break;
}
return selection;
}
sorry for hasseling the functions now work but the menu has stopped working it run the menu then asks for add fucntions statments, once entered it repeats again?