syntax problems.

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • jendrin
    New Member
    • Jul 2007
    • 11

    syntax problems.

    Hello i can't find the error on my program..and i dont know how to end it either.
    [CODE=cpp]#include<iostre am>
    #include<iomani p>
    #include<iomani p>
    #include<cmath>
    #include<string >
    using namespace std;

    void falsi(double& fd, double& fu, double& fr, double d, double u, double r)
    {
    fd=sin(d)+cos(1 +d*d)-1;
    fu=sin(u)+cos(1 +u*u)-1;
    r=((u*fd - d*fu) / (fd - fu));
    fr=sin(r)+cos(1 +r*r)-1;
    }

    void eq(double x, double y)
    {
    int i;
    double fd,fu,fr,u,d,r;
    x*=1;
    y*=1;
    cout<<"The value of Xd=1 and Xu=2\n";
    for (i=4;i<5;i++)
    {
    falsi(fd,fu,fr, d,u,r);
    if (fr > 0 && fd > 0)
    {
    r = d;
    }
    else
    {
    r = u;
    }

    int main()
    {
    char z;
    cout<<"choose letter a, b, or c";
    cin>>z;
    if (z=='a')
    {
    eq(1,2);
    }
    else if (z=='b')
    {
    eq(1,2.5);
    }
    else
    {
    eq(1,1.5);
    }[/CODE]
    Last edited by Ganon11; Aug 16 '07, 02:07 PM. Reason: code tags added, indented
  • sanctus
    New Member
    • Mar 2007
    • 84

    #2
    Originally posted by jendrin
    Hello i can't find the error on my program..and i dont know how to end it either.
    #include<iostre am>
    #include<iomani p>
    #include<iomani p>
    #include<cmath>
    #include<string >
    using namespace std;




    void falsi(double& fd, double& fu, double& fr, double d, double u, double r)
    {
    fd=sin(d)+cos(1 +d*d)-1;
    fu=sin(u)+cos(1 +u*u)-1;
    r=((u*fd - d*fu) / (fd - fu));
    fr=sin(r)+cos(1 +r*r)-1;
    }

    void eq(double x, double y)
    {
    int i;
    double fd,fu,fr,u,d,r;
    x*=1;
    y*=1;
    cout<<"The value of Xd=1 and Xu=2\n";
    for (i=4;i<5;i++)
    {
    falsi(fd,fu,fr, d,u,r);
    if (fr > 0 && fd > 0)
    {
    r = d;
    }
    else
    {
    r = u;
    }

    int main()
    {

    char z;
    cout<<"choose letter a, b, or c";
    cin>>z;
    if (z=='a')
    {
    eq(1,2);
    }
    else if (z=='b')
    {
    eq(1,2.5);
    }
    else
    {
    eq(1,1.5);
    }
    I don't understand why you define in falsi fd and others to be a reference to a double, but then use them in the same way a the normal doubles d, u, r.
    Also what is the sense of x*=1 and y*=1? You don't change anything...

    Comment

    • gpraghuram
      Recognized Expert Top Contributor
      • Mar 2007
      • 1275

      #3
      Originally posted by jendrin
      Hello i can't find the error on my program..and i dont know how to end it either.
      #include<iostre am>
      #include<iomani p>
      #include<iomani p>
      #include<cmath>
      #include<string >
      using namespace std;




      void falsi(double& fd, double& fu, double& fr, double d, double u, double r)
      {
      fd=sin(d)+cos(1 +d*d)-1;
      fu=sin(u)+cos(1 +u*u)-1;
      r=((u*fd - d*fu) / (fd - fu));
      fr=sin(r)+cos(1 +r*r)-1;
      }

      void eq(double x, double y)
      {
      int i;
      double fd,fu,fr,u,d,r;
      x*=1;
      y*=1;
      cout<<"The value of Xd=1 and Xu=2\n";
      for (i=4;i<5;i++)
      {
      falsi(fd,fu,fr, d,u,r);
      if (fr > 0 && fd > 0)
      {
      r = d;
      }
      else
      {
      r = u;
      }

      int main()
      {

      char z;
      cout<<"choose letter a, b, or c";
      cin>>z;
      if (z=='a')
      {
      eq(1,2);
      }
      else if (z=='b')
      {
      eq(1,2.5);
      }
      else
      {
      eq(1,1.5);
      }

      HI,
      please post the code with code tags which will be easier for us to read/understand the code.
      You have couple of } missed.
      Try to use a editor like notepad++ which helps u in finding this.

      Raghuram

      Comment

      • jendrin
        New Member
        • Jul 2007
        • 11

        #4
        What do you suggest i do?this is btw false position method for approximating a root.

        Comment

        • Ganon11
          Recognized Expert Specialist
          • Oct 2006
          • 3651

          #5
          The only syntax errors I noted were that you never finished the eq() function - there are a few }'s missing - and you also didn't finish the main() function in the same manner.

          Comment

          Working...