write a c program to find the roots of a quadratic equation
ax2 + bx + c = 0
Answer Posted / adde.c
#include<stdio.h>
#include<conio.h>
#include<math.h>
void main()
{
float a,b,c,x1,x2,y,z;
printf("Please Enter 3 inputs of a,b,c in This
format:a<space>b<space>c=");
scanf("%f%f%f",&a,&b,&c);
y=(b*b-4*a*c);
if(a==0&&b==0)
{
printf("There is No Solution!!!!");
}
else if(a==0&&b!=0)
{
x1=(-1)*c/b;
printf("x1=%f",x1);
}
else
{
if(y>=0)
{
z=sqrt(y);
x1=((-1)*b+z)/(2*a);
x2=((-1)*b-z)/(2*a);
printf("Value of x1=%f & x2=%f",x1,x2);
}
else
{
printf("Your Equiation Showing an imaginery
value.....!!!!!!");
}
}
getch();
}
Is This Answer Correct ? | 12 Yes | 15 No |
Post New Answer View All Answers
When should the volatile modifier be used?
Why do we need volatile in c?
How are strings stored in c?
What does %p mean c?
What are Macros? What are its advantages and disadvantages?
How can I write a function that takes a format string and a variable number of arguments?
What is void main () in c?
using only #include
explain what is a newline escape sequence?
An instruction which is analysed and acted upon by the processor prior to the compiler going its work a) directive b) constructive c) constant d) absolute mode
What is variable initialization and why is it important?
What are near, far and huge pointers?
Write a program with dynamically allocation of variable.
Explain what is a program flowchart and explain how does it help in writing a program?
What is integer constants?