C Program to find the roots of a quadratic equation

by Nideesh C on April 18, 2011 · 0 comments

in C Programming




#include<stdio.h>
#include<math.h>
void main()
{
int A, B, C;
float disc, deno, x1, x2;
clrscr();
printf(“nnt ENTER THE VALUES OF A,B,C…”);
scanf(“%d,%d,%d”, &A, &B, &C);
disc = (B * B) – (4 * A * C);
deno = 2 * A;
if(disc > 0)
{
printf(“nt THE ROOTS ARE REAL ROOTS”);
x1 = (-B/deno) + (sqrt(disc) / deno);
x2 = (-B/deno) – (sqrt(disc) / deno);
printf(“nnt THE ROOTS ARE…: %f and %fn”, x1, x2);
}
else if(disc == 0)
{
printf(“nt THE ROOTS ARE REPEATED ROOTS”);
x1 = -B/deno;
printf(“nnt THE ROOT IS…: %fn”, x1);
}
else
printf(“nt THE ROOTS ARE IMAGINARY ROOTSn”);
getch();
}

Not Satisfied ? Just search & get the result

Related Posts Plugin for WordPress, Blogger...
Be Sociable, Share!

Related posts:

  1. C program to find and output all the roots of a quadratic equation, for non-zero coefficients.
  2. Sample – Program to find the roots of a quadratic equation.
  3. C Program To find the biggest and smallest number and positions in the given array
  4. C Program – Find the sum of secondary diagonal of a Matrix
  5. C Program – Find the sum of primary diagonal of a Matrix

Leave a Comment

Previous post:

Next post: