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
Explain the use of bit fieild.
Implement bit Array in C.
What is printf () in c?
Describe how arrays can be passed to a user defined function
What is scope and lifetime of a variable in c?
What's a good way to check for "close enough" floating-point equality?
Why string is used in c?
How do we print only part of a string in c?
Explain function?
HOW TO SOLVE A NUMERICAL OF LRU IN OS ??????
How can I make sure that my program is the only one accessing a file?
Using which language Test cases are added in .ptu file of RTRT unit testing???
Define the scope of static variables.
What is the explanation for cyclic nature of data types in c?
Create a structure to specify data on students given below: Roll number, Name, Department, Course, Year of joining Assume that there are not more than 450 students in the college. 1.write a function to print names of all students who joined in a particular year 2.write a function to print the data of a student whose roll number is given