Q:

The arithmetic operation in language c++

0

Write a program to enter two numbers x and y and then perform the arithmetic operations (addition, subtraction, multiplicatio,division) on the two numbers

 

 

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

#include<iostream.h>
Void main()
{
int x,y;
char op;
cout<<"enter two numbers\n";
cin>>x>>y;
cout<<"enter the operator\n";
cin >>op;
Switch(op)
{
case '+' : cout <<x<<"+"<<y<<"="<<x+y; break;
case '-' : cout <<x<<"-"<<y<<"="<<x-y; break;
case '*' : cout <<x<<"*"<<y<<"="<<x*y; break;
case '/' : cout <<x<<"/"<<y<<"="<<x/y; break;
case '%' : cout <<x<<"%"<<y<<"="<<x%y; break;
default:cout<<"i don't know the operator:"<<op;
}
}

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

This question belongs to these collections

Similar questions


need a help?


find thousands of online teachers now