write a c program to find the roots of a quadratic equation
ax2 + bx + c = 0
Answer Posted / rohit
#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 ? | 29 Yes | 21 No |
Post New Answer View All Answers
write a c program for swapping two strings using pointer
What is time complexity c?
How can you pass an array to a function by value?
How can you find the exact size of a data type in c?
Write a C program in Fibonacci series.
Can true be a variable name in c?
What is the best way of making my program efficient?
what is the different bitween abap and abap-hr?
write an algorithm to display a square matrix.
Explain continue keyword in c
the 'sizeof' operator reported a larger size than the calculated size for a structure type. What could be the reason?
where are auto variables stored? What are the characteristics of an auto variable?
What is pointer & why it is used?
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.
Explain what is the advantage of a random access file?