Basic C++ code error

talentedone

Well-Known Member
Joined
Jan 30, 2008
Messages
218
Reaction score
0
Hi Beginner here, I copied this code exactly from "C++ for Dummies"(no smarta$$ comments plz :D ). Anyway it gives me an error right on the bold line does anyone know why? I'm using Dev-C++ 4.9.9.2 to write and execute the 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;
}
 
its the “ it should be ", all over the place.

1>------ Build started: Project: ConsoleApplication11, Configuration: Debug Win32 ------
1> Source.cpp
1> ConsoleApplication11.vcxproj -> c:\users\neutron\documents\visual studio 2013\Projects\ConsoleApplication11\Debug\ConsoleApplication11.exe
========== Build: 1 succeeded, 0 failed, 0 up-to-date, 0 skipped ==========

Compiles fine my side after changing that.
 
Last edited:
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 referring to the inverted commas " the code has it as “. That is not valid syntax.
 
Thank you semaphore, I hereby appoint you as my C++ mentor :). Just out of interest how long have you been coding?
 
Thank you semaphore, I hereby appoint you as my C++ mentor :). Just out of interest how long have you been coding?

Professionally about 12-14(cant really recall), hobbyist included about 20.
 
Top
Sign up to the MyBroadband newsletter
X