My C++ code is not running any numbers ???

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • ImaniNicole1
    New Member
    • Feb 2012
    • 1

    My C++ code is not running any numbers ???

    I have no idea why this is not giving me any numbers.
    It is supposed to be reading x=__ y=___ but instead it is only giving me my first cout .

    Code:
    //Imani Jones' Output of Her First Program
    #include <iostream>
    #include <cmath> 
    using namespace std;
    int main () 
    {
        cout<<"My name is Imani Jones and this is the output of my first program."<<endl<<endl;
        double x, y;
        
            for (x=-3.5;x=3;x=x+0.5) 
        { y=((-4*x)*x*x+(4*x)*x+(25*x)-25)/ ((sqrt(4*x)*x+2)+3*  abs(x+1.5));
        
        if (x<0)
        cout<<" Y is negative "<<endl;
        if (x==0) 
        cout<< "Y is positive "<<endl;
        if (x>0)
        cout<< "Y is positive "<<endl<<endl;
        } 
        
       std::cout <<"My First Program is Complete"<< std::endl; 
       system ("pause");
     return 0; 
    }
    Last edited by Banfa; Feb 6 '12, 09:17 AM. Reason: Added [code]...[/code] tags round the code, please use them in future
  • coderHead
    New Member
    • Feb 2012
    • 6

    #2
    Just pointing this out: for(x=-3.5;x=3;x=x+0.5)

    With x being assigned 3, then the condition for the loop will always equal TRUE and will never end.

    Comment

    • Rabbit
      Recognized Expert MVP
      • Jan 2007
      • 12517

      #3
      Also, you shouldn't use floats for comparisons. They're not accurate.

      Comment

      • whodgson
        Contributor
        • Jan 2007
        • 542

        #4
        apart from fixing the loop where does your code instruct the print out of x and y?

        Comment

        Working...