Design a program to read three integer numbers x, y and z and Evaluate arithmetic division for R, given R = z / (x - y). Use exception handling to throw an exception in case division by zero is attempted
#include <iostream>
using namespace std;
int main()
{
int x,y,z;
double R;
cout<< "Enter number X, Y, Z: ";
cin>>x>>y>>z;
if (x==y){
cout<< " division by zero"<< endl;
}
else
R=(double)z/(x-y);
cout<<"R = "<<R;
return 0;
}
Comments
Leave a comment