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
What do the functions atoi(), itoa() and gcvt() do?
what is use of malloc and calloc?
What are linker error?
How is pointer initialized in c?
What is getch?
What is self-referential structure in c programming?
write a program that types this pattern: 12345678987654321 12345678 87654321 1234567 7654321 123456 654321 12345 54321 1234 4321 123 321 12 21 1 1
List a few unconditional control statement in c.
Write a program to check prime number in c programming?
If null and 0 are equivalent as null pointer constants, which should I use?
Define recursion in c.
There is a practice in coding to keep some code blocks in comment symbols than delete it when debugging. How this affect when debugging?
What is string constants?
In C language what is a 'dangling pointer'?
Tell us two differences between new () and malloc ()?