Advertisement

ax^2+bx+c=0




x=?
#include<conio.h>
#include<stdio.h>
#include<math.h>
void main()
{clrscr();
int a,b,c,x1,x2;
printf("\t\t*********Input a,b,c for ax^2+bx+c=0*********");
printf("\n\n a=");
scanf("%d",&a);
printf("\n b=");
scanf("%d",&b);
printf("\n c=");
scanf("%d",&c);
x1=(-b+sqrt((b*b)-(4*a*c)))/(2*a);
x2=(-b-sqrt((b*b)-(4*a*c)))/(2*a);
printf("\nThe roots are:%d",x1);
printf(" and %d",x2);
getch();}

No comments:

Post a Comment

Please comment bellow. Share your knowledge