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


Please Help Members By Posting Answers For Below Questions

What is a string?

658


What is static volatile in c?

564


Write a program to know whether the input number is an armstrong number.

660


What is calloc in c?

652


what is the format specifier for printing a pointer value?

604






How many bytes are occupied by near, far and huge pointers (dos)?

656


What is the difference between functions abs() and fabs()?

637


Are local variables initialized to zero by default in c?

539


What is the role of && operator in a program code?

559


Who is the main contributor in designing the c language after dennis ritchie?

537


What is the difference between printf and scanf )?

581


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.

3493


Write a program to swap two numbers without using third variable?

808


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.

1205


Explain the difference between call by value and call by reference in c language?

637