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
Hi how many types of software editions are there and their difference (like home editions, enterprise, standard etc) can u please help me
Can you please explain the difference between syntax vs logical error?
Why is c so powerful?
Explain the use of bit fieild.
A text file that contains declarations used by a group of functions,programs,or users a) executable file b) header file c) obj file d) .cfile
write a program in C that prompts the user for today's date,tomorrow's date and display the results.Use structures for today's date,tomorrow's date and an array to hold the days for each month of the year.
What is typeof in c?
Is c object oriented?
please can any one suggest me best useful video tutorials on c i am science graduate.please help me.u can email me to sas29@in.com
What are the similarities between c and c++?
What are the types of macro formats?
Why pointers are used?
How variables are declared in c?
What is the difference between abs() and fabs() functions?
Where register variables are stored in c?