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
Which is not valid in C a) class aClass{public:int x;}; b) /* A comment */ c) char x=12;
Create a simple code fragment that will swap the values of two variables num1 and num2.
WHAT IS THE DEFINATION OF IN TECHNOLOGY AND OFF TECHNOLOGY ?
How do you list a file’s date and time?
What is data structure in c programming?
What is an auto keyword in c?
Explain how can I remove the trailing spaces from a string?
What are the characteristics of arrays in c?
What’s a signal? Explain what do I use signals for?
What is volatile keyword in c?
7-Given an index k, return the kth row of the Pascal's triangle. For example, when k = 3, the row is [1,3,3,1]. For reference look at the following standard pascal’s triangle.
What are the types of data structures in c?
Can you assign a different address to an array tag?
What is array of structure in c?
Write a program for Overriding.