Login Register






What's wrong with my code? C++ filter_list
Author
Message
What's wrong with my code? C++ #1
Hey, I'm putting together a practice program for my learning purposes. The program is meant to convert Celsius degree inputted into Fahrenheit degree outputted.

Here's my source code:

Code:
// // Program to convert temperature from Celsius degree // 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; }

Now here's the errors that came up, & I am unsure how to fix these errors to finish compiling.

Code:
Compiler: Default compiler Executing g++.exe... g++.exe "C:\Users\Patches\Desktop\TempConverter.cpp" -o "C:\Users\Patches\Desktop\TempConverter.exe" -I"C:\Dev-Cpp\lib\gcc\mingw32\3.4.2\include" -I"C:\Dev-Cpp\include\c++\3.4.2\backward" -I"C:\Dev-Cpp\include\c++\3.4.2\mingw32" -I"C:\Dev-Cpp\include\c++\3.4.2" -I"C:\Dev-Cpp\include" -L"C:\Dev-Cpp\lib" C:\Users\Patches\Desktop\TempConverter.cpp: In function `int main(int, char**)': C:\Users\Patches\Desktop\TempConverter.cpp:21: error: `celsius' undeclared (first use this function) C:\Users\Patches\Desktop\TempConverter.cpp:21: error: (Each undeclared identifier is reported only once for each function it appears in.) C:\Users\Patches\Desktop\TempConverter.cpp:23: error: stray '\147' in program C:\Users\Patches\Desktop\TempConverter.cpp:23: error: `Fahrenheit' undeclared (first use this function) C:\Users\Patches\Desktop\TempConverter.cpp:23: error: expected `;' before "value" C:\Users\Patches\Desktop\TempConverter.cpp:23: error: stray '\148' in program C:\Users\Patches\Desktop\TempConverter.cpp:27: error: stray '\147' in program C:\Users\Patches\Desktop\TempConverter.cpp:27: error: stray '\148' in program C:\Users\Patches\Desktop\TempConverter.cpp:27: error: `PAUSE' undeclared (first use this function) Execution terminated

Reply

RE: What's wrong with my code? C++ #2
(11-18-2013, 11:07 PM)Aut•ono•mous Wrote: Hey, I'm putting together a practice program for my learning purposes. The program is meant to convert Celsius degree inputted into Fahrenheit degree outputted.

Here's my source code:

Code:
// // Program to convert temperature from Celsius degree // 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; }

Now here's the errors that came up, & I am unsure how to fix these errors to finish compiling.

Code:
// // Program to convert temperature from Celsius degree // 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; }

I am not trying to judge you but are you sure you haven't copy/pasted the source from a website ?

From the errors I can say that your source code in not functioning because you have to change all-> “ ” to " "

Just try with normal quotes-> " " now it will work.

[Image: HFlSNlq.png]
If you need help , drop me a PM and I will help you with the best I can !

[Image: V7mYdF6.png]



Reply

RE: What's wrong with my code? C++ #3
Also you forgot to actually post the error. Both codeblocks are same. :p
[Image: rytwG00.png]
Redcat Revolution!

Reply

RE: What's wrong with my code? C++ #4
(11-18-2013, 11:42 PM)dR.0xYw0Rm Wrote:
(11-18-2013, 11:07 PM)Aut•ono•mous Wrote: Hey, I'm putting together a practice program for my learning purposes. The program is meant to convert Celsius degree inputted into Fahrenheit degree outputted.

Here's my source code:

Code:
// // Program to convert temperature from Celsius degree // 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; }

Now here's the errors that came up, & I am unsure how to fix these errors to finish compiling.

Code:
// // Program to convert temperature from Celsius degree // 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; }

I am not trying to judge you but are you sure you haven't copy/pasted the source from a website ?

From the errors I can say that your source code in not functioning because you have to change all-> “ ” to " "

Just try with normal quotes-> " " now it will work.

[Image: HFlSNlq.png]

No judgement taken, I'm not copying & pasting, but I am copying from a book I'm learning from. I mentioned its an example I'm learning from. :b

If both are the same, it must not have copied the second time so I'll edit that now!

Reply

RE: What's wrong with my code? C++ #5
(11-19-2013, 12:21 AM)Coder-san Wrote: Also you forgot to actually post the error. Both codeblocks are same. :p

Just fixed it, lol, the second time I copied must not have registered.

Reply

RE: What's wrong with my code? C++ #6
(11-18-2013, 11:42 PM)dR.0xYw0Rm Wrote:
(11-18-2013, 11:07 PM)Aut•ono•mous Wrote: Hey, I'm putting together a practice program for my learning purposes. The program is meant to convert Celsius degree inputted into Fahrenheit degree outputted.

Here's my source code:

Code:
// // Program to convert temperature from Celsius degree // 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; }

Now here's the errors that came up, & I am unsure how to fix these errors to finish compiling.

Code:
// // Program to convert temperature from Celsius degree // 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; }

I am not trying to judge you but are you sure you haven't copy/pasted the source from a website ?

From the errors I can say that your source code in not functioning because you have to change all-> “ ” to " "

Just try with normal quotes-> " " now it will work.

[Image: HFlSNlq.png]

Awesome! That did it! Thanks so much!

Reply