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 malloc() function?
Is c pass by value or reference?
Study the following C program :call_me (myvar)int myvar;{ myvar +- 5; }main(){int myvar;myvar = 3;call_me(myvar);printf("%d ",myvar);What will be printed a) 3 b) 5 c) 8 d) symbol
How many levels of indirection in pointers can you have in a single declaration?
What does the file stdio.h contain?
What do you mean by a sequential access file?
What is the right type to use for boolean values in c? Is there a standard type? Should I use #defines or enums for the true and false values?
What does == mean in texting?
What is #ifdef ? What is its application?
What are comments and how do you insert it in a C program?
Write a program to print "hello world" without using a semicolon?
What is the purpose of & in scanf?
What are the types of assignment statements?
Describe the complexity of Binary search, Quicksort and various other sorting and searching techniques..
Can you pass an entire structure to functions?