+ 3
Rearrange the code to declare two integer variables: a and b, print to the screen the division equation a/b. If b is equal to 0,
2 Antworten
+ 6
b=0 is an runtime error... coz a/b while b=0 is undefined in maths...
if it would have been java u could have used try catch block to handle it....
search about exception handling in c++ for d answer
+ 1
#include<iostream>
#include<cmath>
using namespace std;
int main()
{
Int a,b;
a=12 //assign values for a and b
b= 2
If (b==0)
{ cout<<"invalid value\n";}
else
cout<< a/b ;
Return 0;
}