| View previous topic :: View next topic |
| Author |
Message |
angerist Grandmaster Cheater Supreme
Reputation: 0
Joined: 18 Jun 2007 Posts: 1011 Location: Australia.
|
Posted: Fri Apr 04, 2008 12:55 am Post subject: New to c++ |
|
|
Hey im new to c++ so im making my 2nd application after the helloword lol. I know im hell noob but i'd really like to learn. Thank you .
Theres 1 error i've tried putting ; infront of celsius (all of them).
| Code: | | error C2146: syntax error : missing ';' before identifier 'celsius' |
Source:
| Code: | //
// Program to convert temperature from Celsius degree by julian
// units into Fahrenheit degree units:
// Fahrenheit = Celsius * (212 - 32)/100 + 32
//
#include <cstdio>
#include <cstdlib>
#include <iostream>
using namespace std;
int main(int nNumberofArgs, char* pszArgs[])
// enter the temperature in Celsius
int celsius;
cout << “Enter the temperature in Celsius:”;
cin >> celsius;
// calculate conversion factor for Celsius
// to Fahrenheit
int factor;
factor = 212 - 32;
// use conversion factor to convert Celsius
// into Fahrenheit values
int fahrenheit;
fahrenheit = factor * celsius/100 + 32;
// output the results (followed by a NewLine)
cout << “Fahrenheit value is:”;
cout << fahrenheit << endl;
// wait until user is ready before terminating program
// to allow the user to see the program results
system(“PAUSE”);
return 0; |
_________________
|
|
| Back to top |
|
 |
Deletion I post too much
Reputation: 0
Joined: 22 Jun 2006 Posts: 2148 Location: Underground
|
Posted: Fri Apr 04, 2008 1:18 am Post subject: |
|
|
You don't have any brackets, your quotes are messed up.
Don't just copy and paste code >.>
“ <~~ This is not the same as ~~> "
_________________
Bitch, please.
| redslothx wrote: | | oh im a man so respect the penis powers |
|
|
| Back to top |
|
 |
angerist Grandmaster Cheater Supreme
Reputation: 0
Joined: 18 Jun 2007 Posts: 1011 Location: Australia.
|
Posted: Fri Apr 04, 2008 1:25 am Post subject: |
|
|
Ohhh ok. Thanks
_________________
|
|
| Back to top |
|
 |
hcavolsdsadgadsg I'm a spammer
Reputation: 26
Joined: 11 Jun 2007 Posts: 5801
|
Posted: Fri Apr 04, 2008 1:35 am Post subject: |
|
|
1. { } brackets, use them.
2. weird quotes. " "
3. #include <cstdio>
#include <cstdlib> is pointless.
4. std::cin.sync()
std::cin.ignore()
PAUSE has an enormous overhead.
|
|
| Back to top |
|
 |
angerist Grandmaster Cheater Supreme
Reputation: 0
Joined: 18 Jun 2007 Posts: 1011 Location: Australia.
|
Posted: Fri Apr 04, 2008 3:22 am Post subject: |
|
|
Oh thanks i've fixed it thanks to you slovach
_________________
|
|
| Back to top |
|
 |
Noz3001 I'm a spammer
Reputation: 26
Joined: 29 May 2006 Posts: 6220 Location: /dev/null
|
Posted: Fri Apr 04, 2008 3:41 am Post subject: |
|
|
| Usually happens when you copy stuff from wordpress.
|
|
| Back to top |
|
 |
Deletion I post too much
Reputation: 0
Joined: 22 Jun 2006 Posts: 2148 Location: Underground
|
Posted: Fri Apr 04, 2008 2:29 pm Post subject: |
|
|
Booo, I helped first. D:
_________________
Bitch, please.
| redslothx wrote: | | oh im a man so respect the penis powers |
|
|
| Back to top |
|
 |
Chaosis13 Master Cheater
Reputation: 0
Joined: 14 Aug 2007 Posts: 372
|
Posted: Mon Apr 07, 2008 4:29 pm Post subject: |
|
|
You can do this:
cout << “Fahrenheit value is: ” << fahrenheit << endl;
instead of:
cout << “Fahrenheit value is:”;
cout << fahrenheit << endl;
When using the iostream... They can even look like this:
cout << “F" << "a" << "h" << "r" << "e" << "n" << "h" << "e" << "i" << "t" << " " << "v" << "a" << "l" << "u" << "e" << " " << "i" << "s" << ":" << " ” << fahrenheit << endl;
Thats a bit extream, but it can help with really long segments and other things, works with cin << x << y too.
|
|
| Back to top |
|
 |
|