write a c program to find the roots of a quadratic equation
ax2 + bx + c = 0
Answer Posted / shravya poojitha
#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 ? | 142 Yes | 49 No |
Post New Answer View All Answers
What is typeof in c?
PLS U SENS ME INTERVIEW O. MY EMAIL ADD, SOFIYA.SINGH@GMAIL.COM
When a c file is executed there are many files that are automatically opened what are they files?
What is clrscr ()?
What does typeof return in c?
What is a 'null pointer assignment' error? Explain what are bus errors, memory faults, and core dumps?
How can you find out how much memory is available?
write a program to create a sparse matrix using dynamic memory allocation.
What are the 3 types of structures?
the factorial of non-negative integer n is written n! and is defined as follows: n!=n*(n-1)*(n-2)........1(for values of n greater than or equal to 1 and n!=1(for n=0) Perform the following 1.write a c program that reads a non-negative integer and computes and prints its factorial. 2. write a C program that estimates the value of the mathematical constant e by using the formula: e=1+1/!+1/2!+1/3!+.... 3. write a c program the computes the value ex by using the formula ex=1+x/1!+xsquare/2!+xcube/3!+....
What does == mean in texting?
Find duplicates in a file containing 6 digit number (like uid) in O (n) time.
Explain how do you sort filenames in a directory?
I need testPalindrome and removeSpace
#include
What is the benefit of using const for declaring constants?