#include<conio.h>
#include<iostream.h>
void sum(int, int);
void sub(int, int);
void mul(int, int);
void div(int, int);
void main()
{
clrscr();
int a, b;
char ch;
cout<<"Enter Number: ";
cin>>a;
cout<<"Enter Number: ";
cin>>b;
cout<<"Enter Character: ";
cin>>ch;
switch(ch)
{
case '+' :
sum(a,b);
break;
case '-' :
sub(a,b);
break;
case '*' :
mul(a,b);
break;
case '/' :
div(a,b);
break;
default:
cout<<"Invalid Character Entered";
}
getch();
}
void sum(int x, int y)
{
cout<<"Sum is: "<<x+y;
}
void sub(int x, int y)
{
cout<<"Subtraction is: "<<x-y;
}
void mul(int x, int y)
{
cout<<"Multiplication is: "<<x*y;
}
void div(int x, int y)
{
if (y!=0)
cout<<"Division is: "<<x/y;
else cout<<"Invalid Denomenator";
}
Output |
No comments:
Post a Comment