| View previous topic :: View next topic |
| Author |
Message |
Chidori Grandmaster Cheater
Reputation: 1
Joined: 25 Apr 2008 Posts: 691 Location: Canada
|
Posted: Tue Oct 28, 2008 7:33 pm Post subject: help with farnheit converter |
|
|
i had errors i just fixed em
i need help though when it converts you press a button it closes heres the code it works fine though
#include <cstdlib>
#include <iostream>
using namespace std;
int main(int nNumberofArgs,char* pszArgs[])
{
int Celsius;
cout << "enter the temperature in Celsius :";
cin>> Celsius;
int factor;
factor = 212 - 32;
int Fahrenheit;
Fahrenheit = factor * Celsius/100 + 32;
cout << "Fahrenheit value is :";
cout << Fahrenheit << endl;
system("PAUSE");
return 0;
}
|
|
| Back to top |
|
 |
hcavolsdsadgadsg I'm a spammer
Reputation: 26
Joined: 11 Jun 2007 Posts: 5801
|
Posted: Tue Oct 28, 2008 8:16 pm Post subject: |
|
|
| Don't use system("pause")
|
|
| Back to top |
|
 |
lurc Grandmaster Cheater Supreme
Reputation: 2
Joined: 13 Nov 2006 Posts: 1900
|
Posted: Tue Oct 28, 2008 8:18 pm Post subject: |
|
|
Thats because you aren't looping or anything.
Programs only go in 1 direction, so since you don't have a loop surrounding anything it will print the Fahrenheit then do the pause, then return 0 (exit).
Btw, don't use system("pause"), its the worst way.
Use:
cin.sync();
cin.ignore();
instead.
_________________
|
|
| Back to top |
|
 |
kitterz Grandmaster Cheater Supreme
Reputation: 0
Joined: 24 Dec 2007 Posts: 1268
|
Posted: Tue Oct 28, 2008 8:18 pm Post subject: |
|
|
| slovach wrote: | | Don't use system("pause") |
I agree...use something else.
_________________
|
|
| Back to top |
|
 |
--Pillboi-- Grandmaster Cheater Supreme
Reputation: 0
Joined: 06 Mar 2007 Posts: 1383 Location: I don't understand the question. Is this a 1 to 10 thing?
|
Posted: Wed Oct 29, 2008 4:42 am Post subject: |
|
|
I use getch() from conio.h
_________________
Enter darkness, leave the light, Here be nightmare, here be fright...
Earth and Water, Fire and Air. Prepare to meet a creature rare.
Enter now if you dare, Enter now the dragon's lair. |
|
| Back to top |
|
 |
|