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