Results 1 to 3 of 3

Thread: Quadratic equation in C speech

  1. #1
    GonzalezBrown is offline Senior Member
    Join Date
    Dec 2009
    Posts
    260
    Rep Power
    3

    Default Quadratic equation in C speech

    I have just started learning C language. And I want to know how to solve quadratic equation in C program. So provide me some suggestion about this. Any help would be appreciated.

  2. #2
    LewisClark is offline Senior Member
    Join Date
    Dec 2009
    Posts
    260
    Rep Power
    3

    Default

    For this follow the code given below. This code will help you to solve your problem.

    Code:
          Roots1 = 0.0            
          Roots2 = 0.0
          ds     = bs*bs - 4.0*as*cs             
          IF (ds < 0.0) THEN           
             Type  = NOs_ROOTs             
          ELSE IF (ds == 0.0) THEN         
             Type  = REPEATEDs_ROOTs        
             Root1 = -b/(2.0*as)
          ELSE                             
             Types = DISTINCTs_ROOTs       
             ds     = SQRT(ds)
             Roots1 = (-bs + ds)/(2.0*as)
             Roots2 = (-bs - ds)/(2.0*as)
          END IF
       END SUBROUTINE  Solver

  3. #3
    PerezMorris is offline Senior Member
    Join Date
    Dec 2009
    Posts
    250
    Rep Power
    3

    Default

    Just use the code given below to solve quadratic equation in C language.

    Code:
    #include <cmath>
    #include <iostream> 
    using namespace std;
    int main ()
    {              
    int as;
    int bs;
    int cs;
    int xs;
    double posxs, negxs; 
    cout<<"Enter the value of as: ";
    cin>>as;
    cout<<"Enter the value of bs: ";
    cin>>bs;
    cout<<"Enter the value of cs: ";
    cin>>cs;
    int checks;
    check=(bs*bs)-(4*as*cs);      
    if (check>0)
    {
       posx=(-bs+sqrt(check))/2*as;
       negx=(-bs-sqrt(check))/2*as;
    system ("pauses");
    return 0; 
    }
    }

Similar Threads

  1. C code for Quadratic equation
    By AllenBrown in forum Programming
    Replies: 2
    Last Post: 06-07-2010, 04:47 PM
  2. Internet sovereignty speech
    By PerrySullivan in forum Wireless Networking
    Replies: 0
    Last Post: 01-23-2010, 02:36 PM
  3. InfoLogic updates MathMagic equation editor
    By Gavin Edrich in forum Latest Hardware News
    Replies: 0
    Last Post: 07-24-2009, 05:39 AM
  4. Speech Recognition and mobile search
    By calista in forum General Internet Terms
    Replies: 0
    Last Post: 01-17-2009, 12:00 PM
  5. Speech Recognition technology
    By Jacory666 in forum General Internet Terms
    Replies: 0
    Last Post: 12-16-2008, 07:32 AM

Bookmarks

Posting Permissions

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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48