program to find the roots of a quadratic equation
Answer Posted / vikas tiwari
#include <iostream.h>
#include <conio.h>
#include <math.h>
int main()
{
clrscr();
float a,b,c,d,root1,root2;
cout << "Enter the 3 coefficients a, b, c : " << endl;
cin>>a>>b>>c;
if(!a){
if(!b)
cout << "Both a and b cannot be 0 in ax^2 + bx + c = 0" << "\n";
else
{
d=-c/b;
cout << "The solution of the linear equation is : " << d << endl;
}
}
else
{
d=b*b-4*a*c;
if(d>0)
root1=(-b+sqrt(d))/(2*a);
root2=(-b-sqrt(d))/(2*a);
cout << "The first root = " << root1 << endl;
cout << "The second root = " << root2 << endl;
}
getch();
return 0;
}
Is This Answer Correct ? | 32 Yes | 20 No |
Post New Answer View All Answers
#include
Design an implement of the inputs functions for event mode
To Write a C program to remove the repeated characters in the entered expression or in entered characters(i.e) removing duplicates. String contains only lowercase characters ['a'-'z']
how to programme using switch statements and fuctions, a programme that will output two even numbers, two odd numbers and two prime numbers of the users chioce.
How to palindrom string in c language?
What is full form of PEPSI
could you please send the program code for multiplying sparse matrix in c????
What is the difference between proc means and proc tabulate ? explain with a simple example when you have to use means or tabulate?
How do you verify if the two sentences/phrases input is an anagram using predefined functions in string.h and by using arrays?
Sir... please give some important coding questions asked by product companies..
can you use proc sql to manpulate a data set or would u prefer to use proc report ? if so why ? make up an example and explain in detail
How can I Create a C program in splitting set of characters to specific subsets. Example: INPUT SET OF CHARACTERS: Therefore, my dear brothers and sisters, stand firm. Let nothing move you. Always give yourselves fully to the work of the Lord, because you know that your labor in the Lord is not in vain. SPLIT INTO HOW MANY CHARACTERS PER SUBSETS: 10 OUTPUT: Therefore, my dear b rothers an d sisters, stand fir m. Let not hing move you. Alway s give you rselves fu lly to the work of t he Lord, b ecause you know that your labo r in the L ord is not in vain.
What is the match merge ? compare data step match merge with proc sql merge - how many types are there ? data step vs proc sql
Develop a routine to reflect an object about an arbitrarily selected plane
write a program for area of circumference of shapes