Black_Knight's blog

By Black_Knight, 8 years ago, In English

The Following Code should output "Happy Coding" after certain operations, but it is never printed. When n=0.01 and the statement n-=0.01 executes, it prints 5.52024e^-014. Can anyone explain why it occurs and what the remedy is??

#include <iostream>
#include <cmath>
#include <conio.h>
using namespace std;
int main()
    double n;
        cout<<n<<" "<<endl;

    cout<<"Happy Coding"<<endl;
    return 0;

Thanks in Advance.

Read more »

  • Vote: I like it
  • +5
  • Vote: I do not like it