Search This Blog

Sep 27, 2013

C program to calculate the real roots of quadratic equation

/*roots of quadratic equation*/
#include<conio.h>
#include<stdio.h>
#include<math.h>
void main()
{
int a,b,c,r1,r2,x;
clrscr();
printf("Enter the value of a, b & c:");
scanf("%d%d%d",&a,&b,&c);
x=pow(b,2)-4*a*c;
if(x>=0)
{
r1=(-b+sqrt(x))/(2*a);
r2=(-b-sqrt(x))/(2*a);
printf("Real roots are :%d & %d",r1,r2);
}
else
printf("Given roots are imagenary");
getch();
}

No comments:

Post a Comment