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

Introduction of C-language.

Variable & Datatype for C-programming

Program to see all ASCII value using for loop in C-language

Errors in C-language

Program to find the sum of two array into the third in C-language

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

Program to show present time and date in C-language

Binary searching in C-language

Syntax of C-language