bit4bit
July 4th, 2007, 11:14 AM
Hello all, I'm very new to C++ and just started reading "C++ for dummies". Which is quite good but I have got a small problem with:
Basically the book provides you with little bits of source code as you go along, which you compile with 'Dev C++' to see how it works. The first example is a program to convert degrees celcius to degrees farenheit, and here is the source code for it:
//
// 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;
}
My problem is, when I compile it, this appears on my screen:
[img=http://img262.imageshack.us/img262/1086/devcerrormb3.th.jpg] (http://img262.imageshack.us/my.php?image=devcerrormb3.jpg)
Is this an error in the code? - Have they published bad code in their book?? Or maybe there is some Dev C++ setting that I have set incorrectly? (though it certainly looks like an error even to me)
The accompanying CD provides all the .cpp files for each bit of source code, but I have lost it, and haven't been able to find another.
Is this code really incorrect?
Thanks alot for any help.
-bit4bit
P.S Sorry if this is in the wrong forum, as I said I'm a complete beginner and I didn't know the difference between them :P
EDIT 2: I think this should be in the 'Visual C++ forum'?
Basically the book provides you with little bits of source code as you go along, which you compile with 'Dev C++' to see how it works. The first example is a program to convert degrees celcius to degrees farenheit, and here is the source code for it:
//
// 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;
}
My problem is, when I compile it, this appears on my screen:
[img=http://img262.imageshack.us/img262/1086/devcerrormb3.th.jpg] (http://img262.imageshack.us/my.php?image=devcerrormb3.jpg)
Is this an error in the code? - Have they published bad code in their book?? Or maybe there is some Dev C++ setting that I have set incorrectly? (though it certainly looks like an error even to me)
The accompanying CD provides all the .cpp files for each bit of source code, but I have lost it, and haven't been able to find another.
Is this code really incorrect?
Thanks alot for any help.
-bit4bit
P.S Sorry if this is in the wrong forum, as I said I'm a complete beginner and I didn't know the difference between them :P
EDIT 2: I think this should be in the 'Visual C++ forum'?