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
How can you tell whether two strings are the same?
What is static function in c?
why return type of main is not necessary in linux
What is the difference between a string copy (strcpy) and a memory copy (memcpy)? When should each be used?
Do character constants represent numerical values?
How can I read in an object file and jump to locations in it?
What is #define used for in c?
Calculate 1*2*3*____*n using recursive function??
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?
Where we use clrscr in c?
What are disadvantages of C language.
What are two dimensional arrays alternatively called as?
What is sizeof c?
What is null character in c?
What is memory leak in c?