Tuesday, December 6, 2011

Write a C program to find Root of X as equation ax^2+bx+c=0 where value of a,b,c given by User (Complex Number)

#include <stdio.h>
#include <conio.h>
#include <math.h>
void main()
{
 int a,b,c,x1,x2,d;
 clrscr();
 printf("Enter three value: ");
 scanf("%d %d %d",&a,&b,&c);
 d=sqrt((b*b)-(4*a*c));
 if(d>0)
 {
  x1=(-b+d)/(2*a);
  x2=(-b-d)/(2*a);
  printf("x= %d, %d",x1,x2);
 }
 else
 {
  printf("Your entered value is incorrect %d",d);
 }
 getch();
}

No comments:

Post a Comment