can't find the error

This is a discussion on can't find the error within the C++ Programming forums, part of the General Programming Boards category; I am getting these errors: etoxfunction.cpp:10: parse error before `continue' etoxfunction.cpp: In function `int main ()': etoxfunction.cpp:24: parse error before ...

  1. #1
    Registered User
    Join Date
    Oct 2002
    Posts
    3

    can't find the error

    I am getting these errors:
    etoxfunction.cpp:10: parse error before `continue'
    etoxfunction.cpp: In function `int main ()':
    etoxfunction.cpp:24: parse error before `continue'
    etoxfunction.cpp: At top level:
    etoxfunction.cpp:81: parse error before `continue'
    etoxfunction.cpp:84: syntax error before `<'
    etoxfunction.cpp:85: syntax error before `<'


    with this code:

    Code:
    #include <iostream>
    #include <cmath>
    #include <iomanip>
    
    void intro();
    double getvalue(double& xvalue);
    double calculate(double DELTA, double factorial,int& expntofx, double nthterm, double& xvalue,
    double& sumofterms);
    void showresult(double DELTA, int expntofx, double xvalue, double sumofterms);
    char continue(char response);
    void continloop(char response, double xvalue, double DELTA, double factorial, int expntofx, double nthterm, double sumofterms);
    
    int main()
    {
    double const DELTA = 0.000001;
    double sumofterms = 1;
    double nthterm = 1;
    double xvalue;
    int expntofx = 1;
    double factorial = 1;
    char response;
    
    intro();
    response = continue();
    continloop(response, xvalue, DELTA, factorial,expntofx, nthterm, sumofterms);
    
    
    
    cout<< endl;
    return 0;
    
    }
    
    void intro()
    {
    cout<< endl << endl;
    cout<< " x\n "
    << " APPROXIMATION OF e BY THE METHOD OF TAYLOR'S EXPANSION\n"
    << endl << endl;
    cout<< " This program will calculate the value\n\n"
    << " x\n"
    << " of e using the Taylor Series Expansion Method\n"
    << endl;
    }
    
    double getvalue(double& xvalue)
    {
    cout<< " x\n"
    << " Please enter the value of x in e and press enter: ";
    cin>> xvalue;
    cout<< endl << endl;
    return xvalue;
    }
    
    double calculate(double DELTA, double factorial,int& expntofx, double nthterm, double& xvalue,
    double& sumofterms)
    {
    while(abs(nthterm) > DELTA)
    {
    factorial *= expntofx;
    nthterm = (pow(xvalue, expntofx))/(factorial);
    sumofterms += nthterm;
    expntofx++;
    }
    
    return sumofterms;
    }
    
    void showresult(double DELTA, int expntofx, double xvalue, double sumofterms)
    {
    cout<< " With a precision of " << DELTA << ","
    << " and with " << ++expntofx << " terms\n\n"
    << "x\n";
    cout<< " The value of e, where x = " << xvalue << " is: ";
    cout<< setiosflags(ios::fixed) << setprecision(7);
    cout<< sumofterms\n;
    cout<< endl << endl << endl;
    }
    
    void continue(char response)
    {
    char response;
    cout<< " Do you wish to continue?(Y/N)\n";
    cin<< response;
    return response;
    }
    
    void continloop(char response, double xvalue, double DELTA, double factorial, int expntofx, double nthterm, double sumofterms)
    {
    while((response == 'Y') || (response == 'y'))
    {
    getvalue(xvalue);
    calculate(DELTA, factorial, expntofx, nthterm, xvalue, sumofterms);
    showresult(DELTA, expntofx, xvalue, sumofterms);
    }
    
    }
    what could be the problem?


    &#91;code]&#91;/code]tagged by Salem

  2. #2
    Refugee face_master's Avatar
    Join Date
    Aug 2001
    Posts
    2,052
    >> Oh, and learn how to indent code - it will make your life much easier in the long run

    Yeah, if you're using MSVC++, just use Alt+F8 to automatically indent it for you

  3. #3
    Just a Member ammar's Avatar
    Join Date
    Jun 2002
    Posts
    953
    The protoype of continue() says that it has one argument but you called the function in main() with no arguments.
    char continue(char response);
    response = continue();
    Ofcourse you should also change the name of continue.

    Hint: Maybe you want to make default arguments for the function continue.
    Try fixing these errors then if you have any others just post them here!

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. An error is driving me nuts!
    By ulillillia in forum C Programming
    Replies: 5
    Last Post: 04-04-2009, 09:15 PM
  2. Using VC Toolkit 2003
    By Noobwaker in forum Windows Programming
    Replies: 8
    Last Post: 03-13-2006, 06:33 AM
  3. using c++ in c code
    By hannibar in forum C Programming
    Replies: 17
    Last Post: 10-28-2005, 09:09 PM
  4. pointer to array of objects of struct
    By undisputed007 in forum C++ Programming
    Replies: 12
    Last Post: 03-02-2004, 03:49 AM
  5. Couple C questions :)
    By Divx in forum C Programming
    Replies: 5
    Last Post: 01-28-2003, 12:10 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21