![]() |
|
#1
|
|||
|
|||
Issues converting Fahrenheit to celcius [was: ok another one blowing my mind ...]/*The code below was taken straight from Sam's book for demonstrating the use of local variables and parameters. Is supposed to convert Fahrenheit to celsius. Doesn't work though, keeps bailing out after first number is entered in program. I wrote it using my own method in code as seen below this this and seems to work fine converting the temperature both ways using the correct math. I'm glad it works and is more useful using my method but, I think I'm not learning the point by getting creative here. Any ideas why the book style doesn't work*/
CPP / C++ / C Code:
CPP / C++ / C Code:
Last edited by JdS : 08-Mar-2004 at 04:56.
Reason: Please use a better title in your thread
|
|
#2
|
||||
|
||||
|
Skampy, the reason the first version bails out after the number is entered is not an error. The program successfully completes its job, then exits. Try adding your system("pause"); at the end of the first version, before the return 0; part.
|
|
#3
|
|||
|
|||
many thanks that is partially workingthe program now gives the celsius temp then the press to continue option and bails. Based on the textbook this is supposed to be the output:
Please enter the temperature in Fahrenheit: 212 Here's the temperature in Celsius: 100 *now i'm getting the press to continue and it exists. *the rest of these i'm not seeing even after I tried adding the system pause in the second function as well Please enter the temperature in Fahrenheit: 32 Here's the termperature in Celsius: 0 Please enter the temperature in fahrenheit: 85 Here's the temperature in Celsius: 29.4444 *maybe could be my compiler i guess Quote:
|
|
#4
|
||||
|
||||
|
Hi Skampy.
One thing real quick that helps a ton when you post code. If you place [c] before your code and [/c] after your code, it will be highlighted as I have editted above. I think that it is great that you are experimenting with different ways to do things in C/C++. The book was probably trying to show the use of functions. Functions are the key to good programming (IMHO). Anyway, it appears that you got it to work both ways. |
|
#5
|
||||
|
||||
|
Quote:
CPP / C++ / C Code:
|
|
#6
|
|||
|
|||
Re: Issues converting Fahrenheit to celsiusHey, I was having the same problem... But there is a solution. Its Simple too.
all you have to do is open you're command prompt (start/run/cmd) and click and drag your compiled file into it then press enter... It will run it and not kill it's self after you press a key. Hope I helped. |
|
#7
|
||||
|
||||
Re: Issues converting Fahrenheit to celsiusQuote:
![]() __________________
Age is unimportant -- except in cheese |
|
#8
|
||||
|
||||
Re: Issues converting Fahrenheit to celsiusReally, it doesn't matter how old this (or any other) thread is.
What matters is that any new posts / replies appended to it are relevant, up to date, and/or useful. If it's not, just say so or better yet, use the "Report Bad Post" button to have them (useless posts) deleted. |
Recent GIDBlog
Python ebook by crystalattice
| Thread Tools | Search this Thread |
| Rate This Thread | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| newbie using Sam's series | Skampy | C++ Forum | 3 | 06-Mar-2004 18:51 |
| (read/write file) newbie need help plz | momotx | C Programming Language | 6 | 28-Jan-2004 13:40 |
| Newbie help with unary ops | Tony | C Programming Language | 2 | 04-Jan-2004 19:10 |
| newbie help | milwalt | C++ Forum | 1 | 27-Dec-2003 11:52 |
| total newbie need help | grunt123 | Apache Web Server Forum | 2 | 04-Dec-2003 11:14 |
Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The