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
Explain what is gets() function?
What is the difference between memcpy and memmove?
How can you convert integers to binary or hexadecimal?
WRITE A CODE IN C TO SEARCH A FILE FROM NOTEPAD FILE.
An instruction which is analysed and acted upon by the processor prior to the compiler going its work a) directive b) constructive c) constant d) absolute mode
Explain null pointer.
What is #line in c?
How can I write a function analogous to scanf?
What are pointers? What are different types of pointers?
write a program in c language to print your bio-data on the screen by using functions.
Difference between strcpy() and memcpy() function?
What are the advantages of c language?
Explain the properties of union. What is the size of a union variable
Why flag is used in c?
What is the purpose of 'register' keyword?