#include<iostream.h>
int x,y;
int sum(int a,int b)
{
int c;
c = a+b;
return (c);
}
int sub (int a ,int b)
{
int c;
c = a-b ;
return (c);
}
int multi ( int a, int b )
{
int c ;
c = a*b;
return (c);
}
float div ( int a , int b)
{
float c;
c = a/b ;
return (c);
}
main()
{
cout<<"enter the value of x = ";
cin>>x;
cout<<"enter the value of y = ";
cin>>y;
cout<<"x + y = "<< sum(x,y);
cout<<"\n x - y = "<< sub(x,y);
cout<<"\n x * y = "<< multi(x,y);
cout<<"\n x /y = "<< div (x,y);
cin>>"\n";
}
I am sorry if I misunderstand, but a switch loop is used instead of a lot of if's and else if's. You seem to not be doing that so I don't see wherefore the switch would serve. Please tell me if i am wrong!
You are right in that the code contains neither an if-else nor a switch-case. You are also right that it can be used instead of a lot of if-else statements. One thing not right, it isn't any kind of loop.