Search Your Keyword

A One Massage for users

C Program BD say you

Hi, If you are new in our blog and to get support about C program, than you must select your level from right side in this blog.Such as, If you want to learn than you select Entry Level for learning and If you are known the basic of C program than you select Solution Level.


Saturday, September 14, 2019

Q5. Write a C program that calculates all possible roots of a quadratic equation.

C program that calculates all possible roots of a quadratic equation:-
#include<stdio.h>
#include<conio.h>

void main()
{
float a, b, c, d, root, root1, root2;
clrscr();

printf("Enter a, b and c");
scanf("%f %f %f", &a, &b, &c);


d=b*b-4*a*c;
if(d<0)
{
printf("\n Roots are imaginary");
}

else if(d==0)
{
root=-b/2*a;
printf("\n Root = %f",root);
}

else
{
root1 = (-b+sqrt(d))/(2*a);
root2 = (-b-sqrt(d))/(2*a);
printf("Root1 = %.2f \n Root2 = %.2f",root1,root2);
}

getch();

}

Solve the quadratic equation in C programming

C program that calculates all possible roots of a quadratic equation, Quadratic equation in c programming, C program of quadratic equation. .


No comments:

Post a Comment