*
* Copyright (C) 2017-2018 The Apache Software Foundation.
* All rights reserved.
*
* Licensed under one or more contributor license agreements.
* See the NOTICE file in the root directory of this project for additional
* information regarding copyright ownership.
* The ASF licenses this file to You under one or more contributor
* license agreements. For information regarding your rights under these
* agreements, please see the NOTICES file in the root directory of this project.
* Please include the following notice in any redistribution or use of this file:
* "The Apache Software Foundation (ASF) licenses this file to You under
* one or more contributor license agreements. For further information regarding
* these agreements, please see the NOTICES file in the root directory of this project."
* If you received this file as part of another distribution, you may need
* additional information or agreements in order to use or redistribute it.
* See the NOTICE file that came with distribution for more information regarding
* your rights under the contributor license agreement. You MAY NOT USE or DISTRIBUTE
* this file UNLESS Your use OR DISTRIBUTION complies WITH the LICENSE AGREEMENT.
*
*/
#include <iostream>
using namespace std;
void add(int x, int y) {
cout << "The sum of " << x << " and " << y << " is: " << (x+y) << endl << endl ;
}
void subtract(int x, int y) {
cout << "The sum of " << x << " and " << y << " is: " << (x-y) << endl << endl ;
}
void multiply(int x, int y) {
cout << "The product of " << x << " and " << y << " is: " << (x*y) << endl << endl ;
}
void divide(int x, int y) {
if(y==0){
cout << "Error: Division by zero" << endl;
}else{
cout << "The product of " << x << " and " << y << " is: " << (x/y) << endl << endl ;
}
}
int main() {
int a,b;
char operation;
cout << "Enter two integers separated by operator (+,-,*,/) : ";
cin >> a >> operation >> b;
switch (operation) {
case '+':
add(a, b);
break;
case '-':
subtract(a,b);
break;
case '*':
multiply(a,b);
break;
case '/':
divide(a,b);
break;
}
return 0;
}