Program to find real roots of quadreatic equation in C-language

Program to find real roots of quadreatic equation in C-language

#include<stdio.h>
#include<math.h>
int main()
{
    float a,b,c,X,Y;
    printf("Only for real roots\n");
printf("Enter the value of coefficient x^2\n");
scanf("%f",&a);
  printf("Enter the value of coefficient x\n");
  scanf("%f",&b);
  printf("Enter the value of constant\n");
    scanf("%f",&c);
    X=(-b+(sqrt((b*b)-(4*a*c))))/(2*a);
    Y=(-b-(sqrt((b*b)-(4*a*c))))/(2*a);
    printf("Roots are \nx=%f \ny=%f",X,Y);
}

OUTPUT
Only for real roots
Enter the value of coefficient x^2
1
Enter the value of coefficient x
4
Enter the value of constant
4
Roots are
x=-2
y=-2

This program help you to find roots of quardetic equation and this program is perfect example of sqrt function.

If you like this program then you can share it and for any issues you can direct contact with me from Home Page.


For regular updates you can also follow my site.



Comments

Popular posts

Creative pattern of butterfly in C-language

Program to cheque enter number is even or odd in c-language

Program to print the cube of a number in c-language

Creative Pattern of Rhino in C-language

Variable & Datatype for C-programming

Division of two numbers in C-language