You are on page 1of 3

Aim: A progam that performs simple arithmetic calculation

With a menu that has

1. Add
2. Sub
3. Div
4. multi
5.Mod
6. Quit

# include <iostream.h>
# include <conio.h>
void add()
{
float a,b,sum;
cout<<" Enter two numbers"<<endl;
cin>>a>>b;
sum=a+b;
cout<<"The sum is"<<sum<<endl;
}
void mult()
{
float a,b,mult;
cout<<"Enter the numbers"<<endl;
cin>>a>>b;
mult=a*b;
cout<<"The answer is"<<mult<<endl;
}
void sub()
{
float a,b,sub;
cout<<"Enter the number"<<endl;
cin>>a>>b;
sub=a-b;
cout<<"The numberis "<<sub<<endl;
}
void div()
{
float a,b,div;
cout<<"Enter the number"<<endl;
cin>>a>>b;
div=a/b;
cout<<"The answer is"<<div<<endl;
}
void mod()

{
int a,b,mod;
cout<<"Enter the Number"<<endl;
cin>>a>>b;
mod=a%b;
cout<<"The answer is "<<mod<<endl;
}
void main()
{
int opt;
clrscr();
loop:
cout<<"\t\t Select your operation"<<endl;
cout<<"\t *************************************\n"<<endl;
cout<<"\t\t1. Add\n"<<endl;
cout<<"\t\t2. Mul\n"<<endl;
cout<<"\t\t3. Div\n"<<endl;
cout<<"\t\t4. Sub\n"<<endl;
cout<<"\t\t5. Mod\n"<<endl;
cout<<"\t\t6. Exit\n"<<endl;
cout<<"Select the operation by entering the coresponding number\n"<<endl;
cin>>opt;
cout<<"You have selected the operation with number:\n"<<opt<<endl;
switch(opt)
{
case 1:
add();
goto loop;
break;
case 2:
mult();
goto loop;
break;
case 3:
div();
goto loop;
break;
case 4:
sub();
goto loop;
break;
case 5:
mod();
goto loop;
break;
case 6:
break;
default:
cout<<"The number selected does not exist"<<endl;
goto loop;

break;
}
}

You might also like