home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!munnari.oz.au!goanna!gtj
- From: gtj@goanna.cs.rmit.oz.au (Glenn T Jayaputera)
- Newsgroups: comp.lang.c++
- Subject: Need Help on trivial issue
- Message-ID: <14497@goanna.cs.rmit.oz.au>
- Date: 13 Sep 92 12:23:56 GMT
- Organization: RMIT Department of Computer Science
- Lines: 25
-
- Hi, I need help on the following program. The problem I have is if I
- input the value > 1.1 the string "Yahooo....." is only printed once.
- I dont Understand why n==of only for a value of 0.5 not 1.0, 1.5, 2.0, etc.
-
- Can somebody please pointed out which part I am missing.
-
- #include <iostream.h>
-
- main() {
- double x;
- double n=0.1, of=0.5;
-
- cout << "Input x : "; cin >> x;
-
- while (n<x) {
- n += 0.1;
- if (n==of) {
- cout << "Yahooooo...\n";
- of +=0.5;
- }
- }
- }
-
- Thanks in advance
- Glenn Jayaputera
-