home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #20 / NN_1992_20.iso / spool / comp / lang / cplus / 13572 < prev    next >
Encoding:
Text File  |  1992-09-13  |  812 b   |  35 lines

  1. Path: sparky!uunet!munnari.oz.au!goanna!gtj
  2. From: gtj@goanna.cs.rmit.oz.au (Glenn T Jayaputera)
  3. Newsgroups: comp.lang.c++
  4. Subject: Need Help on trivial issue
  5. Message-ID: <14497@goanna.cs.rmit.oz.au>
  6. Date: 13 Sep 92 12:23:56 GMT
  7. Organization: RMIT Department of Computer Science
  8. Lines: 25
  9.  
  10. Hi, I need help on the following program.  The problem I have is if I
  11. input the value > 1.1 the string "Yahooo....." is only printed once.
  12. I dont Understand why n==of only for a value of 0.5 not 1.0, 1.5, 2.0, etc.
  13.  
  14. Can somebody please pointed out which part I am missing.
  15.  
  16. #include <iostream.h>
  17.  
  18. main()  {
  19.   double x;
  20.   double n=0.1, of=0.5;
  21.  
  22.   cout << "Input x : "; cin >> x;
  23.  
  24.   while (n<x)  {
  25.     n += 0.1;
  26.     if (n==of)  {
  27.       cout << "Yahooooo...\n";
  28.       of +=0.5;
  29.     }
  30.   }
  31. }
  32.  
  33. Thanks in advance
  34. Glenn Jayaputera
  35.