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
#include main() { int *p, *c, i; i = 5; p = (int*) (malloc(sizeof(i))); printf(" %d",*p); *p = 10; printf(" %d %d",i,*p); c = (int*) calloc(2); printf(" %d ",*c); }
Why we use void main in c?
Can we change the value of static variable in c?
What is the difference between call by value and call by reference in c?
What are data structures in c and how to use them?
Is a house a mass structure?
Why doesn't C support function overloading?
What do you mean by a sequential access file?
What are different storage class specifiers in c?
explain what is an endless loop?
What is the use of sizeof () in c?
my project name is adulteration of chille powder.how can i explain it to the hr when he asks me about the project?
How can I trap or ignore keyboard interrupts like control-c?
Explain argument and its types.
Why is c called a mid-level programming language?