Go4Expert

Go4Expert (http://www.go4expert.com/)
-   C++ (http://www.go4expert.com/forums/cpp/)
-   -   Difference between Pointers and Reference in C++ (http://www.go4expert.com/forums/difference-pointers-reference-cpp-t6292/)

pritish 11Sep2007 11:55

Re: Difference between Pointers and Reference in C++
 
why this behave like this
Code:

void main()
{
      double  a=0.0;
      int i;
      for(i=0;i<=9;i++)
      {
      a+=0.1;
      }
      printf("%lf",a);//--------------->1.000000
      if(a==1.000000)
        printf("yes");
      else
        printf("no");
}

ouput--------no
why output is always no. please explain it.

shabbir 11Sep2007 18:05

Re: Difference between Pointers and Reference in C++
 
Because of floating point approximation. Debug it to see that is the exact value of the variable a

shabbir 11Sep2007 18:06

Re: Difference between Pointers and Reference in C++
 
Also Don't jump into an article with your query and place it in the right forum so that all can respond. I have moved your post this time.


All times are GMT +5.5. The time now is 12:45.