Subscribe to Feeds

Send Your Projects To georgepj@hotmail.com

We'll Publish It With Your Name :-)

Programs Can Also Be Downloaded From The Folders Below....[Or Scroll Down]

Compute Quadratic Equation

Click Here To Download C File Of This Program

 //Program to Compute Quadratic Equations  
//Downloaded from www.c4cprog.co.nr
#include<conio.h>
#include<math.h>
void main()
{
int a,b,c,d;
float r1,r2;
clrscr();
printf("\nEnter the Values of the coefficients a,b,c : \n");
scanf("%d%d%d",&a,&b,&c);
d=(b*b)-(4*a*c);
if(d==0)
{
printf("\nThe Roots are REAL & EQUAL\nRoots Are : \n");
r1=(-b)/(2.0*a);
r2=r1;
printf("1)%f 2)%f",r1,r2);
}
else
{
if(d>0)
{
printf("\nThe Roots are REAL & DISTINCT\nRoots are : \n");
r1=((-b)+sqrt(d))/(2.0*a);
r2=((-b)-sqrt(d))/(2.0*a);
printf("1)%f 2)%f",r1,r2);
}
else
{
printf("\nThe Roots are IMAGINARY\nRoots Are : \n");
d=-d;
r1=(-b)/(2.0*a);
r2=(sqrt(d))/(2.0*a);
printf("1)%f+i%f",r1,r2);
printf("2)\n%f-i%f",r1,r2);
}
}
getch();
}
/*
Enter the Values of the coefficients a,b,c :
1
-4
4
The Roots are REAL & EQUAL
Roots Are :
1)2.000000 2)2.000000
*/

0 comments:

Post a Comment