-4
Wie verwende ich Switch Case in diesem Code? Ich habe es mehrmals versucht, aber ich weiß wirklich nicht, wie ich es ohne Fehler machen kann.Wie verwendet man den Schalter in C++?
#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";
}
http://en.cppreference.com/w/cpp/language/switch –
bitte Ihren Code einrücken: es ist eine gute Praxis – bibi