Code Snippet :
#include<iostream>
using namespace std;
int main()
{
int i = 10, j = 5;
int modResult = 0;
int divResult = 0;
modResult = i % j;
cout << modResult << " ";
divResult = i/modResult;
cout << divResult;
return 0;
}
Error :
Floating point exception
Description :
It should give a divide by zero exception. But since the statement is 'i/modResult', where modResult is a variable it won't give this error. Instead, it returns a floating point exception.
#include<iostream>
using namespace std;
int main()
{
int i = 10, j = 5;
int modResult = 0;
int divResult = 0;
modResult = i % j;
cout << modResult << " ";
divResult = i/modResult;
cout << divResult;
return 0;
}
Error :
Floating point exception
Description :
It should give a divide by zero exception. But since the statement is 'i/modResult', where modResult is a variable it won't give this error. Instead, it returns a floating point exception.
No comments:
Post a Comment