C Program Solving Quadratic Equation
/* Write a program to solve Quadratic Equation. */
#include <stdio.h>
int main(void) {
int a,b,c,delta;
float x1,x2;
printf("Enter Co-efficient of X2 : ");
scanf("%d",&a);
printf("Enter Co-efficient of X : ");
scanf("%d",&b);
printf("Enter Constant : ");
scanf("%d",&c);
delta = (b *b)-(4*a*c);
x1 = (-b + sqrt(delta))/(2*a);
x2 = (-b - sqrt(delta))/(2*a);
printf("\n First Root = %.2f \n Second Root = %.2f",x1,x2);
return 0;
}
#include <stdio.h>
int main(void) {
int a,b,c,delta;
float x1,x2;
printf("Enter Co-efficient of X2 : ");
scanf("%d",&a);
printf("Enter Co-efficient of X : ");
scanf("%d",&b);
printf("Enter Constant : ");
scanf("%d",&c);
delta = (b *b)-(4*a*c);
x1 = (-b + sqrt(delta))/(2*a);
x2 = (-b - sqrt(delta))/(2*a);
printf("\n First Root = %.2f \n Second Root = %.2f",x1,x2);
return 0;
}
Comments
Post a Comment