Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people's questions, and connect with other people.

Have an account? Sign In

Captcha Click on image to update the captcha.

Have an account? Sign In Now

Sign In

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

Sorry, you do not have a permission to ask a question, You must login to ask question.

Forgot Password?

Need An Account, Sign Up Here
Tech Answered Logo Tech Answered Logo
Sign InSign Up

Tech Answered

Tech Answered Navigation

  • Home
  • Tutorials
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • About Us
  • Blog
  • Contact Us
Home / Questions /Q 359
Next
Answered
shree
shree

shree

  • India
  • 138 Questions
  • 69 Answers
  • 2 Best Answers
  • 200 Points
View Profile
  • -2
shree
Asked: August 15, 20202020-08-15T21:29:15+05:30 2020-08-15T21:29:15+05:30In: C Language

c program to solve quadratic equation with algorithm

  • -2

im just stuck at programming to solve quadratic equation,im doing this on C language,can anyone show a example C program to solve quadratic equation and if there is algorithm that would be a real help…

c programsquadraticquadratic equation c program
  • 4
  • 5,853
  • 0
  • 0
Answer
Share
  • Facebook

    Related Questions

    • How do you find the factorial of a number in C using while loops?

    4 Answers

    1. Krishna Vijayan

      Krishna Vijayan

      • India
      • 8 Questions
      • 218 Answers
      • 9 Best Answers
      • 0 Points
      View Profile
      Best Answer
      Krishna Vijayan
      2020-08-16T19:40:38+05:30Added an answer on August 16, 2020 at 7:40 pm

      You can use the program given below to find the roots of a quadratic equation. It’s a pretty simple program.

      The output of the program will have two sections :

      • Enter The Quadratic Equation In The Format ax^2+bx+c :
      • Roots Of The Quadratic Equation Will Be :

      Program:

      int main(){
      float a,b,c;
      float d,root1,root2;

      printf(“Enter quadratic equation in the format ax^2+bx+c: “);
      scanf(“%fx^2%fx%f”,&a,&b,&c);

      d = b * b – 4 * a * c;

      if(d < 0){
      printf(“Roots are complex number.\n”);

      return 0;
      }

      root1 = ( -b + sqrt(d)) / (2* a);
      root2 = ( -b – sqrt(d)) / (2* a);
      printf(“Roots of quadratic equation will be: %.3f , %.3f”,root1,root2);

      return 0;
      }

       

      Run it

      • 0
      • Reply
      • Share
        Share
        • Share on Facebook
        • Share on Twitter
        • Share on LinkedIn
        • Share on WhatsApp
      • shree

        shree

        • India
        • 138 Questions
        • 69 Answers
        • 2 Best Answers
        • 200 Points
        View Profile
        shree
        2020-08-17T15:44:59+05:30Replied to answer on August 17, 2020 at 3:44 pm

        thanks for sharing this….

        • 0
        • Reply
        • Share
          Share
          • Share on Facebook
          • Share on Twitter
          • Share on LinkedIn
          • Share on WhatsApp
    2. Pubali Halder
      2020-08-25T11:13:35+05:30Added an answer on August 25, 2020 at 11:13 am

      C Language is learned as a basic programming language in schools and engineering degrees for CSE Departments. 

      In this language, we think of logic and solve a question by writing programs and executing them. We execute every program to check whether it is correct syntactically as well as logically.

      If you couldn’t solve quadratic equation with an algorithm in C program, don’t worry, I am here to help you out.

      Algorithm:

      The following steps have to be followed to write a program to solve the quadratic equation:

      1. The value of a, b and c is to be entered.
      2. Calculate the value of discriminant, “d = b^2 – 4ac”
      3. Check whether d is less than 0 or greater than 0.
      4. d is imaginary if it is “less than 0”
      5. Other than the above step, if the conditions are different then “find 2 real roots”
      6. Roots are displayed as output.

      Program:

      #include<stdio.in>

      #include<math.h> 

      main()

      {

      int a,b,c,d,rt1,rt2;

      printf(“Enter the values of a,b and c: “);

      scanf(“%d%d%d”,&a,&b,&c);

      d = pow(b,2) – 4*a*c;

      if(d<0)

         {

                printf(“Imaginary Roots”);

                printf(“\n rt1= %.3d% + .3fi\n”, -b/(2*a),sqrt(-d)/(2*a));

                printf(“\n rt2= %.3d% + .3fi\n”, -b/(2*a),sqrt(-d)/(2*a));

          } 

      else

          {

                rt1 = (-b + sqrt(d))/(2*a);

                rt2 = (-b – sqrt(d))/(2*a);

                printf(“First root = %d and Second root = %d”,rt1,rt2);

          }

      return 0;

      }

      All the steps mentioned above which are involved in the algorithm and program are for finding or solving the quadratic equation in C language. 

      If you found this answer useful, make sure to like it. Also, share it with people who are going to write a program in C to solve the quadratic equation.

      • 3
      • Reply
      • Share
        Share
        • Share on Facebook
        • Share on Twitter
        • Share on LinkedIn
        • Share on WhatsApp
    3. arunraj503

      arunraj503

      • 28 Questions
      • 31 Answers
      • 2 Best Answers
      • 85 Points
      View Profile
      arunraj503
      2023-11-02T15:27:36+05:30Added an answer on November 2, 2023 at 3:27 pm

      im dropping the code to solve quadratic with absolute C program.

      you can copy this quadratic solution program in c if you want.

      #include <stdio.h>
      #include <math.h>

      int main() {
      double a, b, c;
      double discriminant, root1, root2;

      printf(“Enter the coefficients a, b, and c: “);
      scanf(“%lf %lf %lf”, &a, &b, &c);

      // Calculate the discriminant
      discriminant = b * b – 4 * a * c;

      if (discriminant > 0) {
      // Two real and distinct roots
      root1 = (-b + sqrt(discriminant)) / (2 * a);
      root2 = (-b – sqrt(discriminant)) / (2 * a);
      printf(“Root 1 = %.2lf and Root 2 = %.2lf\n”, root1, root2);
      } else if (discriminant == 0) {
      // One real root (double root)
      root1 = -b / (2 * a);
      printf(“Double Root = %.2lf\n”, root1);
      } else {
      // Complex roots
      double realPart = -b / (2 * a);
      double imaginaryPart = sqrt(-discriminant) / (2 * a);
      printf(“Complex Roots: %.2lf + %.2lfi and %.2lf – %.2lfi\n”, realPart, imaginaryPart, realPart, imaginaryPart);
      }

      return 0;
      }

      see the solution for factorial of a number in c. 

      • 0
      • Reply
      • Share
        Share
        • Share on Facebook
        • Share on Twitter
        • Share on LinkedIn
        • Share on WhatsApp
    Leave an answer

    Leave an answer
    Cancel reply

    Browse

    Sidebar

    Ask A Question

    More Questions

    • glenn

      code for matrix multiplication in c

    • Tech savvy

      c keep asking for input how to write a program

    • Mingle tap

      How do you find the factorial of a number in

    • Namrata

      What Is A "null Pointer Assignment" Error? What Are Bus

    • Hari

      What is OOPs concept in C++ with examples?

    • Samakshi baghel

      What is the use of github?

    • Samakshi baghel

      How to fix broken commit

    • shree

      in turbo c how to change the cursor

    Stats

    • Questions 1,991
    • Answers 2,102
    • Posts 12
    • Best Answers 73

    Related Questions

    • Mingle tap

      How do you find the factorial of a number in C using

    Explore

    • Home
    • Communities
    • Questions
      • New Questions
      • Trending Questions
      • Must read Questions
      • Hot Questions
    • Polls
    • Tags
    • Badges
    • Users
    • Help

    Footer

    Recent Comments

    • muller on how to solve export problem in kinemaster
    • muller on how to solve export problem in kinemaster
    • muller on how to solve export problem in kinemaster
    • AaronBlackburn on why can’t i find my message requests on instagram
    • shree on How to use philips citrus press juicer 25 watts Demo
    Ask A Question

    Archives

    Tags

    laptop buying guide (1) limit google news notifications (1) printer buying guide (1) stop google news notifications (1) turn off google news notifications (1)

    Social media

    © 2023 @ Techanswered.com.
    Terms, Privacy policy & Sitemap.

    Insert/edit link

    Enter the destination URL

    Or link to existing content

      No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.