Write a C++ program that will receive two integers from the user and store the numbers in locations called numerator and denominator. Calculate and output the result of the division if the denominator is not equal to zero otherwise output a message stating division by zero is an illegal operation. - C++ Programs Codes

Latest

Sunday, 31 January 2021

Write a C++ program that will receive two integers from the user and store the numbers in locations called numerator and denominator. Calculate and output the result of the division if the denominator is not equal to zero otherwise output a message stating division by zero is an illegal operation.

 CODE:


#include<iostream>
using namespace std;
int main(){
int a,b,c;
cout<<"Division of 2 Numbers\n";
cout<<"Enter the value of A: ";
cin>>a;
cout<<"Enter the value of B: ";
cin>>b;
if(b==0){
cout<<"Divison by zero is illegal in math!\n";
return 0;
}
else{
c=a/b;
cout<<"Answer is : "<<c<<endl;
}
return 0;
}

OUTPUT:



No comments:

Post a Comment

Plz don't enter any spam link in the comment box!