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

Hi how many types of software editions are there and their difference (like home editions, enterprise, standard etc) can u please help me

1437


Can you please explain the difference between syntax vs logical error?

666


Why is c so powerful?

651


Explain the use of bit fieild.

680


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

623






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.

4960


What is typeof in c?

579


Is c object oriented?

515


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

1295


What are the similarities between c and c++?

574


What are the types of macro formats?

584


Why pointers are used?

600


How variables are declared in c?

538


What is the difference between abs() and fabs() functions?

575


Where register variables are stored in c?

529