Hi there,
I am stuck in a problem in which my function rounds off a decimal point number upto 4 decimal place and return a 0.0000 number. But when i compare this returned number to 0 it did not return true in if condition.
Please check my code below and tell me if something i am doing wrong. Its sounds simple but i don't know why that condition is skipping. Thanks !
#include <iostream>
#include <math.h> //to use sin function
#include <iomanip>
using namespace std;
double funct(double x)
{
double fx;
fx = sin(x) - (5*x) + 2;
cout<<fixed <<setprecision(4);
return fx;
}
int main()
{
double no;
no = funct(0.495);
cout<<"returned no = " <<no <<endl;
if(no == 0)
cout<<"\nzero";
else
cout<<"\nnot zero";
return 0;
}