CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 7 of 7
  1. #1
    Join Date
    Dec 2002
    Location
    Birmingham UK
    Posts
    83

    Please help with this code

    I have leart C programming in pass and then i stop once i pass my exam and of course you know what happends next you forget it !

    i am trying to learn C++ and therefore bought this book C++ for Dummies

    i am getting some erros with this code line 37 it says string not termiated now i have try alsort of things but no good.

    / This is a PA from what i have learnt chap01 to chap 04
    //this program will do addition , times, sharing , subtractions.
    #include <stdio.h>
    #include <iostream.h>


    int main()

    {

    int num1,num02,total;
    float num1f,num2f,totalf;


    cout <<"*************************************"<"\n";
    cout <<"** Dynex Basic Maths Program **"<"\n";
    cout <<"*************************************"<"\n";
    cout <<" ************* "<\n";
    cout <<" **** "<"\n";
    cout <<" ** "<"\n";


    cout <<"\n";
    cout <<"Enter the first digit:"<<"\n";
    cin >> num1;
    cout <<"\n";
    cout <<"Now enter the second digit:"<<"\n";
    cin >> num2;
    cout <<"\n";

    total = num1 + num2;
    cout <<" Your total sum is:"
    cout << total;

    cout <<"\n";
    cout <<"*********************************"<< "\n";
    cout <<" Programs ends "<< "\n";
    // this is were the error happens ? cout <<"*********************************"<< "\n";

    return 0;






    }


    please help me
    Waheed Rafiq

    www.waheedrafiq.com


    MCP x 2 , Network+.CNNA

  2. #2
    Join Date
    Nov 2001
    Location
    Beyond Juslibol
    Posts
    1,688
    If the code is this

    cout <<" Programs ends "<< "\n";
    // this is were the error happens ? cout <<"*********************************"<< "\n";

    try this

    cout <<" Programs ends "<< "\n";
    // this is were the error happens ? cout
    cout <"*********************************"<< "\n";

  3. #3
    Join Date
    May 2000
    Location
    Phoenix, AZ [USA]
    Posts
    1,347
    I ran your code through my compiler and fixed all of the errors
    that cropped up. Most of them were simple typos [putting <
    instead of << for the extraction stream operator or not enclosing
    a string inside double quotes]. You should use the headers that
    I specified, however. The old header files that you used before
    are deprecated in the standard and may be in older text books,
    but they are not guaranteed to exist in the real world [though
    they will probably exist for years].

    Code:
    // This is a PA from what i have learnt chap01 to chap 04
    //this program will do addition , times, sharing , subtractions.
    #include <cstdio>
    #include <iostream>
    using namespace std;
    
    
    int main()
    
    {
    
    int num1,num2,total;
    float num1f,num2f,totalf;
    
    
    cout <<"*************************************"<<"\n";
    cout <<"** Dynex Basic Maths Program **"<<"\n";
    cout <<"*************************************"<<"\n";
    cout <<" ************* "<<"\n";
    cout <<" **** "<<"\n";
    cout <<" ** "<<"\n";
    
    
    cout <<"\n";
    cout <<"Enter the first digit:"<<"\n";
    cin >> num1;
    cout <<"\n";
    cout <<"Now enter the second digit:"<<"\n";
    cin >> num2;
    cout <<"\n";
    
    total = num1 + num2;
    cout <<" Your total sum is:";
    cout << total;
    
    cout <<"\n";
    cout <<"*********************************"<< "\n";
    cout <<" Programs ends "<< "\n";
    // this is were the error happens ? 
    cout <<"*********************************"<< "\n";
    
    return 0;
    
    
    
    
    
    
    }
    --Paul

  4. #4
    Join Date
    Aug 1999
    Location
    India
    Posts
    15
    I also tried to remove all errors (very simple)

    the code is:


    // This is a PA from what i have learnt chap01 to chap 04
    //this program will do addition , times, sharing , subtractions.
    #include <stdio.h>
    #include <iostream.h>


    int main()

    {

    int num1,num2,total;
    float num1f,num2f,totalf;


    cout <<"*************************************"<<"\n";
    cout <<"** Dynex Basic Maths Program **"<<"\n";
    cout <<"*************************************"<<"\n";
    cout <<" ************* "<<"\n";
    cout <<" **** "<<"\n";
    cout <<" ** "<<"\n";


    cout <<"\n";
    cout <<"Enter the first digit:"<<"\n";
    cin >> num1;
    cout <<"\n";
    cout <<"Now enter the second digit:"<<"\n";
    cin >> num2;
    cout <<"\n";

    total = num1 + num2;
    cout <<" Your total sum is:";
    cout << total;

    cout <<"\n";
    cout <<"*********************************"<< "\n";
    cout <<" Programs ends "<< "\n";
    // this is were the error happens ?
    cout <<"*********************************"<< "\n";

    return 0;






    }

  5. #5
    Join Date
    Dec 2002
    Location
    Birmingham UK
    Posts
    83

    Talking

    My god i never even dream of getting a reply back so thanks to all of you who have help me with this


    can any of you warrirors help or point me to the right directions

    i am currently using rhide version 1.4 which came with this dummies book is this a good complier or can i find a better one for free.



    many thanks the code works and i have leart something new today .
    Waheed Rafiq

    www.waheedrafiq.com


    MCP x 2 , Network+.CNNA

  6. #6
    Join Date
    Apr 1999
    Posts
    27,449
    Originally posted by waheedrafiq
    My god i never even dream of getting a reply back so thanks to all of you who have help me with this


    can any of you warrirors help or point me to the right directions

    i am currently using rhide version 1.4 which came with this dummies book is this a good complier or can i find a better one for free.



    many thanks the code works and i have leart something new today .
    If the compiler still uses old headers such as <iostream.h> instead of the standard <iostream>, then you better get another (more modern) compiler.

    Regards,

    Paul McKenzie

  7. #7
    Join Date
    Dec 2002
    Posts
    2
    There are several good "free" (still be sure to read and honor the licenses, though!) compilers and IDEs available on the web. One that is quickly becoming my favorite is Dev-C++ (available at www.bloodshed.net) - I've dabbled with the latest beta with the latest Mwing CRT library for some smaller, educational projects, and even though the IDE is still somewhat quirky, the gcc compiler is very good.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured