write a c program to find the roots of a quadratic equation
ax2 + bx + c = 0
Answer Posted / lazy guyz
#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 ? | 1 Yes | 7 No |
Post New Answer View All Answers
What is a const pointer?
What should malloc() do?
Do you know the purpose of 'register' keyword?
Given two strings S1 and S2. Delete from S2 all those characters which occur in S1 also and finally create a clean S2 with the relevant characters deleted.
What is pointer to pointer in c with example?
Differentiate between new and malloc(), delete and free() ?
What is a loop?
What are the advantages of using new operator as compared to the function malloc ()?
How can I copy just a portion of a string?
Some coders debug their programs by placing comment symbols on some codes instead of deleting it. How does this aid in debugging?
What are the benefits of organizational structure?
Explain what are compound statements?
What is the use of sizeof () in c?
What is the most efficient way to count the number of bits which are set in an integer?
What is a macro, and explain how do you use it?