Wednesday, March 24, 2021

4.13. Write a program that read three numbers(a,b,c) and determine the roots of the quadratic equation:

#include<stdio.h>
#include<conio.h> 
#include<math.h>
void main () {
int a,b,c,d; float x1,x2,p,q;
clrscr(); printf("a= ");
scanf("%d",&a); printf ("b= ");
scanf ("&d", &b);
printf("c= ");
scanf("%d", &c);
d=b*b-4*a*c;
if (d>0)
{
x1= (-b+sqrt (d))/(2*a);
x2= (-b-sqrt (d))/(2*a);
printf("\nxl= %.2f\nx2= $.2f", x1, x2)
}
else if (d==0)
{
x1=x2%3-b/(2*a);
printf("\nx1%= %.2f\nx2= %.2f", x1, x2);
}
else
p=-b/(2*a);
Party be ru
q=sqrt(-d)/(2*a);
printf("\nx1-8.2f+8.2fi \nx23%.2f-%.2fi",p,q,p,q);
}
getch();
}

No comments:

Post a Comment