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
What are the usage of pointer in c?
What is static memory allocation?
What are c preprocessors?
What does the c in ctime mean?
What are the primitive data types in c?
How is actual parameter different from the formal parameter?
How can I write functions that take a variable number of arguments?
what is the format specifier for printing a pointer value?
What are the 5 types of organizational structures?
Explain the process of converting a Tree into a Binary Tree.
Study the following C program :call_me (myvar)int myvar;{ myvar +- 5; }main(){int myvar;myvar = 3;call_me(myvar);printf("%d ",myvar);What will be printed a) 3 b) 5 c) 8 d) symbol
How can I get back to the interactive keyboard if stdin is redirected?
How does normalization of huge pointer works?
What is a floating point in c?
Differentiate fundamental data types and derived data types in C.