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

Answer Posted / abc

#include<stdio.h>
#include<conio.h>
void main()
{
int a,b,c,root;
float x1,x2;
printf("enter the roots a,b,c");
scanf("%d %d %d",&a,&b,&c);
if(a=0&&b=0)
printf("no solution");
else
if(a=0)
{
root=-c/b;
printf("root=%d",root);
}
else
if[(b*b-4*a*c)>0]
{
x1=[-b+sqrt (b*b-4*a*c)]/(2*a);
x2=[-b-sqrt (b*b-4*a*c)]/(2*a);
printf("the roots are x1=%f,x2=%f",x1,x2);
}
else
printf("it has imaginary roots");
getch();
}

Is This Answer Correct ?    8 Yes 11 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is the difference between ā€˜gā€™ and ā€œgā€ in C?

2591


I have written a pro*C program to fetch data from the cursor. where in i have used the concept of BULK FETCH.... each FETCH statement is taking lots of time to fetch specified number of rows at...

9662


What is omp_num_threads?

587


In a switch statement, what will happen if a break statement is omitted?

605


Why structure is used in c?

598






What is the g value paradox?

647


What is null in c?

602


Which type of language is c?

656


Difference between constant pointer and pointer to a constant.

615


Is a pointer a kind of array?

602


What is structure packing in c?

612


Can a void pointer point to a function?

575


Is null always defined as 0(zero)?

617


what are enumerations in C

726


What is #include stdlib h?

618