Hi Guys trying to implement basic code for converting temperature from Celsius to Fahrenheit. It is code from the C++ for dummies book 5th edition. I get the following errors when I compile:
1>------ Rebuild All started: Project: ConsoleApplication1, Configuration: Debug Win32 ------
1> Source.cpp
1>c:\users\max\documents\visual studio 2013\projects\consoleapplication1\consoleapplication1\source.cpp(10): error C2065: '“Enter' : undeclared identifier
1>c:\users\max\documents\visual studio 2013\projects\consoleapplication1\consoleapplication1\source.cpp(10): error C2146: syntax error : missing ';' before identifier 'the'
1>c:\users\max\documents\visual studio 2013\projects\consoleapplication1\consoleapplication1\source.cpp(10): error C2065: 'the' : undeclared identifier
1>c:\users\max\documents\visual studio 2013\projects\consoleapplication1\consoleapplication1\source.cpp(10): error C2146: syntax error : missing ';' before identifier 'temperature'
1>c:\users\max\documents\visual studio 2013\projects\consoleapplication1\consoleapplication1\source.cpp(10): error C2065: 'temperature' : undeclared identifier
1>c:\users\max\documents\visual studio 2013\projects\consoleapplication1\consoleapplication1\source.cpp(10): error C2146: syntax error : missing ';' before identifier 'in'
1>c:\users\max\documents\visual studio 2013\projects\consoleapplication1\consoleapplication1\source.cpp(10): error C2065: 'in' : undeclared identifier
1>c:\users\max\documents\visual studio 2013\projects\consoleapplication1\consoleapplication1\source.cpp(10): error C2146: syntax error : missing ';' before identifier 'Celsius'
1>c:\users\max\documents\visual studio 2013\projects\consoleapplication1\consoleapplication1\source.cpp(10): error C2065: '”' : undeclared identifier
1>c:\users\max\documents\visual studio 2013\projects\consoleapplication1\consoleapplication1\source.cpp(21): error C2065: '“Fahrenheit' : undeclared identifier
1>c:\users\max\documents\visual studio 2013\projects\consoleapplication1\consoleapplication1\source.cpp(21): error C2146: syntax error : missing ';' before identifier 'value'
1>c:\users\max\documents\visual studio 2013\projects\consoleapplication1\consoleapplication1\source.cpp(21): error C2065: 'value' : undeclared identifier
1>c:\users\max\documents\visual studio 2013\projects\consoleapplication1\consoleapplication1\source.cpp(21): error C2146: syntax error : missing ';' before identifier 'is'
1>c:\users\max\documents\visual studio 2013\projects\consoleapplication1\consoleapplication1\source.cpp(21): error C2065: '”' : undeclared identifier
1>c:\users\max\documents\visual studio 2013\projects\consoleapplication1\consoleapplication1\source.cpp(25): error C2065: '“PAUSE”' : undeclared identifier
========== Rebuild All: 0 succeeded, 1 failed, 0 skipped ==========
Code is below , thanks !
#include <cstdio>
#include <cstdlib>
#include <iostream>
using namespace std;
int main()
{
// 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;
}
This looks like you used some kind of word processor on this code. You will need to delete and retype all the quotation marks, because they are non-ASCII characters.
Also once you get those problems ironed out you'll probably have problems with your calculations. Remember there are no fractional parts of an int so 1/2 will yield zero.