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 string?
What is static volatile in c?
Write a program to know whether the input number is an armstrong number.
What is calloc in c?
what is the format specifier for printing a pointer value?
How many bytes are occupied by near, far and huge pointers (dos)?
What is the difference between functions abs() and fabs()?
Are local variables initialized to zero by default in c?
What is the role of && operator in a program code?
Who is the main contributor in designing the c language after dennis ritchie?
What is the difference between printf and scanf )?
write a program to convert a expression in polish notation(postfix) to inline(normal) something like make 723+* (2+3) x 7 (not sure) just check out its mainly printing expression in postfix form to infix.
Write a program to swap two numbers without using third variable?
how can i write a program that prints out a box such that whenever i press any key8(coordinate number) on the keyboard, the box moves.
Explain the difference between call by value and call by reference in c language?