write a c program to find the roots of a quadratic equation
ax2 + bx + c = 0

Answer Posted / patel mac p

#include<stdio.h>
#include<conio.h>
#include<math.h>
void main()
{
clrscr();
int a,b,c,d;
float x1,x2,root;
printf("\nEnter the value of a,b,c");
scanf("%d %d %d",&a,&b,&c);
d=(b*b)-(4*a*c);
if(a==0&&b==0)
{
printf("\nNO SOLUTION");
}
else
if(a==0&&b!=0)
{
root=-c/b;
printf("ROOT=%f",root);
}
else
if(d>=0)
{
printf("\nROOTS ARE REAL");
x1=(-b+sqrt(d))/(2*a);
x2=(-b-sqrt(d))/(2*a);
printf("\nX1=%f",x1);
printf("\nx2=%f",x2);
}
else
if(d<0)
{
printf("\nTHIS EQUATION HAS IMAGINARY ROOTS");
}
getch();
}

Is This Answer Correct ?    11 Yes 15 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is s or c?

604


What is strcpy() function?

662


Explain what is a stream?

615


How pointers are declared?

571


What is the purpose of & in scanf?

606






Explain how do you use a pointer to a function?

644


write a program to print data of 5 five students with structures?

1616


What is difference between constant pointer and constant variable?

638


the statement while(i) puts the entire logic in loop. this loop is called a) indefinite loop b) definite loop c) loop syntax wrong d) none of the above

613


write a program to print largest number of each row of a 2D array

1878


Is struct oop?

590


Explain what are multibyte characters?

633


What do mean by network ?

665


The process of repeatedly running a set of computer instructions until some condition is specifed a) condition b) sequential condition c) global d) iteration

638


Why c is faster than c++?

637