Ask your own question, for FREE!
Computer Science 22 Online
OpenStudy (anonymous):

Write a C++ prgm to find roots by using quadratic formula?

OpenStudy (zepp):

DO EET

OpenStudy (zepp):

First try to declare the variables you need, write your code here.

OpenStudy (zepp):

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

OpenStudy (zepp):

I'll be right back.

OpenStudy (anonymous):

#include<iostream.h> void main() { int a,b,c; cout<<"Enter the first number?", cin>>a;

OpenStudy (anonymous):

@zepp like this

OpenStudy (anonymous):

shall i continue of any mistakes

OpenStudy (zepp):

This is perfect

OpenStudy (anonymous):

#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;

OpenStudy (anonymous):

hw wat to do?

OpenStudy (anonymous):

hw to insert quad formula

OpenStudy (zepp):

Make another variable Variable = Formula; Output Variable

OpenStudy (anonymous):

wat i have add like this int a,b,c,x; .........then wat

OpenStudy (anonymous):

@zepp r u there

OpenStudy (anonymous):

@nick67 wat should i do!

OpenStudy (nick67):

@Yahoo! do you know how to solve it with paper and pen ?

OpenStudy (zepp):

Ookay, back.

OpenStudy (zepp):

\[\LARGE \frac{-b\pm\sqrt{b^2-4ac}}{2a}\]

OpenStudy (nick67):

@zepp how did you write a so big formula ...?

OpenStudy (zepp):

That's the quadratic formula?

OpenStudy (nick67):

yes, I mean the character size

OpenStudy (zepp):

\LARGE

OpenStudy (nick67):

cool, thank you

OpenStudy (zepp):

yw

OpenStudy (anonymous):

hw to insert this is prgm

OpenStudy (anonymous):

@zepp @nick67 Plzz help

OpenStudy (anonymous):

i mean quad formula

OpenStudy (nick67):

@Yahoo! hint: divide formula into smaller pieces

OpenStudy (anonymous):

No idea ! o

OpenStudy (nick67):

which steps do you execute to solve the problem by hand ?

OpenStudy (zepp):

#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; }

OpenStudy (zepp):

http://puu.sh/Nkk9

OpenStudy (anonymous):

thxxx

OpenStudy (anonymous):

Can u work out Physics

OpenStudy (anonymous):

Motion in 2-D

OpenStudy (zepp):

No :(

OpenStudy (anonymous):

@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)

OpenStudy (zepp):

I got no error while compiling

OpenStudy (anonymous):

i got an error saying abt using pow

Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!
Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!