New to cpp programming! ^.^

2012-01-13
2012-09-26
  • DawnOfSkies
    DawnOfSkies
    2012-01-13

    Hello my name Is DawnOfSkies, and me and my buddies were talking about making
    a game but we all agreed that without a coder the game will never be made into
    reality, so i took it upon myself to be that coder I am also the project
    manager and director, we are a small team of six people. right now im reading
    C++ for dummies in order to learn how to code in C++.

    Making a game will come later as the kind of game im trying to make needs far
    more skill than i currently have but its only a matter of time before i can
    grasp the commands and intricacies of C++.

    im no idiot, in fact a tend to learn really fast when i can understand what im
    being told. but im verbally awkward so unless someone doesn't just tell me to
    google it, im willing to hear advice from programmers about stuf like making a
    library for my compilers my blocks compiler doesnt compile propperly cint i
    didnt have a full libfor c++.

    Im trying to make a program to calculate a conversion from celsius to
    fahrenheitso here's what the book made me write in the text editor:

    //
    // 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 compiler is finding errors on lines with the #include so it doesnt compile
    properly. What am i doing wrong?
    I think maybe because i didn't have the official book and the cd i couldn't do
    this command as i dont have a cstlib or cstdio.
    I was using blocks application at the time.

     
  • Tor E Syversen
    Tor E Syversen
    2012-01-14

    replase the ? sign with " then it runs on my system (win7 and dewc++)
    typing as following:

    //
    // 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;
    }

     
  • Tor E Syversen
    Tor E Syversen
    2012-01-14

    cange ? with " and it runs
    T Syversen

     

  • Anonymous
    2012-02-29

    Your getting that error because you copied and pasted from a pdf file the code you displayed. In the pdf file it uses a special character for " so for each instance in the program where you have a " that was copied and pasted it looks like the correct character is there but it isn't a real " that you would get from using your keyboard to type it.
    I have the same ebook, took me a few minutes to figure it out as well. :)