Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- using namespace std;
- int main () {
- int n1,n2;
- char operato;
- cin >> n1 >> n2 >> operato;
- if (operato=='+'){
- int result=n1+n2;
- if(result%2==0){
- cout << n1 <<" + "<<n2<<" = "<<result<<" - even"<<endl;
- }else if (result%2==1){
- cout << n1 <<" + "<<n2<<" = "<<result<<" - odd"<<endl;
- }
- }else if(operato=='-'){
- int result=n1-n2;
- if(result%2==0){
- cout << n1 <<" - "<<n2<<" = "<<result<<" - even"<<endl;
- }else if (result%2==1){
- cout << n1 <<" - "<<n2<<" = "<<result<<" - odd"<<endl;
- }
- }else if(operato=='*'){
- int result=n1*n2;
- if(result%2==0){
- cout << n1 <<" * "<<n2<<" = "<<result<<" - even"<<endl;
- }else if (result%2==1){
- cout << n1 <<" * "<<n2<<" = "<<result<<" - odd"<<endl;
- }
- }
- else if(operato=='/' ){
- if (n2!=0){
- double dResult=(n1*1.00)/n2;
- cout.setf(ios::fixed);
- cout.precision(2);
- cout << n1 <<" / "<<n2<<" = "<<dResult<<endl;
- }else if (n2==0)
- cout << "Cannot divide "<<n1<<" by zero" << endl;
- }else if(operato=='%'){
- if (n2!=0){
- int result=n1%n2;
- cout << n1 <<" % "<<n2<<" = "<<result<<endl;
- }else if (n2==0)
- cout << "Cannot divide "<<n1<<" by zero" << endl;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement