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


Please Help Members By Posting Answers For Below Questions

What is malloc() function?

638


Is c pass by value or reference?

595


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

667


How many levels of indirection in pointers can you have in a single declaration?

595


What does the file stdio.h contain?

608






What do you mean by a sequential access file?

629


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?

608


What does == mean in texting?

668


What is #ifdef ? What is its application?

649


What are comments and how do you insert it in a C program?

742


Write a program to print "hello world" without using a semicolon?

597


What is the purpose of & in scanf?

598


What are the types of assignment statements?

630


Describe the complexity of Binary search, Quicksort and various other sorting and searching techniques..

647


Can you pass an entire structure to functions?

696