Write a C++ prgm to find roots by using quadratic formula?
DO EET
First try to declare the variables you need, write your code here.
We'll need three variables, a, b and c Ask the user to enter all three; >Declare the nature of these variables >Use cout and cin to get the values of them
I'll be right back.
#include<iostream.h> void main() { int a,b,c; cout<<"Enter the first number?", cin>>a;
@zepp like this
shall i continue of any mistakes
This is perfect
#include<iostream.h> void main() { int a,b,c; cout<<"Enter the first number?", cin>>a; cout<<" enter second number?"; cin>>b, cout<<" enter third number?"; cin>>c;
hw wat to do?
hw to insert quad formula
Make another variable Variable = Formula; Output Variable
wat i have add like this int a,b,c,x; .........then wat
@zepp r u there
@nick67 wat should i do!
@Yahoo! do you know how to solve it with paper and pen ?
Ookay, back.
\[\LARGE \frac{-b\pm\sqrt{b^2-4ac}}{2a}\]
@zepp how did you write a so big formula ...?
That's the quadratic formula?
yes, I mean the character size
\LARGE
cool, thank you
yw
hw to insert this is prgm
@zepp @nick67 Plzz help
i mean quad formula
@Yahoo! hint: divide formula into smaller pieces
No idea ! o
which steps do you execute to solve the problem by hand ?
#include <iostream> using namespace std; #include <cmath> int main() { double a, b, c; // Declaring variables cout << "a? "; cin >> a; cout << "b? "; cin >> b; cout << "c? "; cin >> c; double const discriminant = (pow(b,2) + (4 * a*c) ); // Discriminant: sqrt(b^2 + 4ac) double result1 = ((0 - b) + discriminant)/ (2 * a); // First result, -b+sqrt(b^2+4ac)/2a double result2= ((0 - b) - discriminant)/ (2 * a); // Second result, -b-sqrt(b^2+4ac)/2a cout << result1 << endl; // Display result1 cout << result2 << endl; // Display results return 0; }
thxxx
Can u work out Physics
Motion in 2-D
No :(
@zepp there is solme error in this i am not getting double const discriminant = (pow(b,2) + (4 * a*c) ); // Discriminant: sqrt(b^2 + 4ac)
I got no error while compiling
i got an error saying abt using pow
Join our real-time social learning platform and learn together with your friends!