Welocome to the Cyber Console. The world of Cyber Geeks. Cyber Console is a community forum of GeeTech Inc.


You are not connected. Please login or register

View previous topic View next topic Go down  Message [Page 1 of 1]

1 Solving Quadratic equations on Sun Sep 18, 2011 12:38 am

Kannan

avatar
Admin
Admin
This is a simple C Program to find the roots of a quadratic equation:

Code:
#include<stdio.h>
#include<math.h>
void main()
{
int A, B, C;
float disc, deno, x1, x2;
clrscr();
printf("\n\n\t 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("\n\t THE ROOTS ARE REAL ROOTS");
x1 = (-B/deno) + (sqrt(disc) / deno);
x2 = (-B/deno) - (sqrt(disc) / deno);
printf("\n\n\t THE ROOTS ARE...: %f and %f\n", x1, x2);
}
else if(disc == 0)
{
printf("\n\t THE ROOTS ARE REPEATED ROOTS");
x1 = -B/deno;
printf("\n\n\t THE ROOT IS...: %f\n", x1);
}
else
printf("\n\t THE ROOTS ARE IMAGINARY ROOTS\n");
getch();
}


___________________________________
http://cyberconsole.finddiscussion.com

View previous topic View next topic Back to top  Message [Page 1 of 1]

Permissions in this forum:
You cannot reply to topics in this forum