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

Answer Posted / shravya poojitha

#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 ?    142 Yes 49 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

How can you tell whether two strings are the same?

837


What is static function in c?

641


why return type of main is not necessary in linux

1710


What is the difference between a string copy (strcpy) and a memory copy (memcpy)? When should each be used?

633


Do character constants represent numerical values?

848






How can I read in an object file and jump to locations in it?

585


What is #define used for in c?

618


Calculate 1*2*3*____*n using recursive function??

1527


When reallocating memory if any other pointers point into the same piece of memory do you have to readjust these other pointers or do they get readjusted automatically?

813


Where we use clrscr in c?

715


What are disadvantages of C language.

653


What are two dimensional arrays alternatively called as?

672


What is sizeof c?

617


What is null character in c?

695


What is memory leak in c?

639