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
Linked list is a Linear or non linear explain if linear how it working as a non linear data structures
State two uses of pointers in C?
What are multidimensional arrays?
What does *p++ do?
Differentiate between a for loop and a while loop? What are it uses?
What is a union?
Why can arithmetic operations not be performed on void pointers?
What is #define used for in c?
Are there any problems with performing mathematical operations on different variable types?
#include main() { char s[] = "Bouquets and Brickbats"; printf(" %c, ",*(&s[2])); printf("%s, ",s+5); printf(" %s",s); printf(" %c",*(s+2)); }
Why c is called procedure oriented language?
Distinguish between actual and formal arguments.
Explain c preprocessor?
Write a program on swapping (100, 50)
Where are c variables stored in memory?