C Program to find roots of quadriatic expression - c programs
//write a c program to find roots of quadriatic expression
//C Program to find roots of quadriatic expression
#include<stdio.h>
void main()
{
int a,b,c,d;
float root1,root2;
printf("Enter the values of a,b,c");
scanf("%d%d%d",&a,&b,&c);
d=b*b-4*a*c;
root1=((-b)+sqrt(d))/(2*a);
root2=((-b)-sqrt(d))/(2*a);
printf("The roots of quadriatic expression are");
printf("root1=%f and root2=%f",root1,root2);
}
//Nature of roots of quadriatic expression
#include<stdio.h>
#include<math.h>
void main()
{
int A, B, C;
float d,deno,x1, x2;
clrscr();
printf("\n\n\t ENTER THE VALUES OF A,B,C...");
scanf("%d,%d,%d", &A, &B, &C);
d = (B * B) - (4 * A * C);
deno = 2 * A;
if(d > 0)
{
printf("\n\t THE ROOTS ARE REAL ROOTS");
x1 = (-B/deno) + (sqrt(d / deno);
x2 = (-B/deno) - (sqrt(d) / deno);
printf("\n\n\t THE ROOTS ARE...: %f and %f\n", x1, x2);
}
else if(d == 0)
{
printf("\n\t THE ROOTS ARE IDENTICAL ROOTS");
x1 = -B/deno;
printf("\n\n\t THE ROOT IS...: %f\n", x1);
}
else
printf("\n\t THE ROOTS ARE IMAGINARY ROOTS\n");
getch();
}
//write a c program to find roots of quadriatic expression
//roots of quadriatic expression in / using c language
//C Program to find roots of quadriatic expression
#include<stdio.h>
void main()
{
int a,b,c,d;
float root1,root2;
printf("Enter the values of a,b,c");
scanf("%d%d%d",&a,&b,&c);
d=b*b-4*a*c;
root1=((-b)+sqrt(d))/(2*a);
root2=((-b)-sqrt(d))/(2*a);
printf("The roots of quadriatic expression are");
printf("root1=%f and root2=%f",root1,root2);
}
//Nature of roots of quadriatic expression
#include<stdio.h>
#include<math.h>
void main()
{
int A, B, C;
float d,deno,x1, x2;
clrscr();
printf("\n\n\t ENTER THE VALUES OF A,B,C...");
scanf("%d,%d,%d", &A, &B, &C);
d = (B * B) - (4 * A * C);
deno = 2 * A;
if(d > 0)
{
printf("\n\t THE ROOTS ARE REAL ROOTS");
x1 = (-B/deno) + (sqrt(d / deno);
x2 = (-B/deno) - (sqrt(d) / deno);
printf("\n\n\t THE ROOTS ARE...: %f and %f\n", x1, x2);
}
else if(d == 0)
{
printf("\n\t THE ROOTS ARE IDENTICAL ROOTS");
x1 = -B/deno;
printf("\n\n\t THE ROOT IS...: %f\n", x1);
}
else
printf("\n\t THE ROOTS ARE IMAGINARY ROOTS\n");
getch();
}
No comments:
Post a Comment