fix programming error
errors, and logic errors.
#Beginner
Runtime and logical error are difficult to identify.
In gcc c++ compiler using namespace std;
#include <iostream>
using namespace std;
int main()
{
float i = 17;
float j = 0;
cout << "runtime error 17/0 :" << i / j;
cout << endl;
cout << "logic error 17/7 :" << 17 / 7;
cout << endl;
cout << "fix logic error 17/7 :" << 17.0 /7;
return 0;
}
Output
runtime error 17/0 :inf
logic error 17/7 :2
fix logic error 17/7 :2.42857
[Program finished]
Runtime error is zero can't dived any number.
Logic error are more difficult to identify in big calculation and big program to solve the error just apply type casting to fix error. In above example 17 divided by 7 is show int value when apply 17.0 divided by 7 the compiler identify the floating points is anser then they show 2.42857 .Best Sellers in Software
Comments
Post a Comment
Any doubt about programming or questions