HELLO EVERYONE! IM A NOVICE C++ USER AS I HAVE BEEN STUDYING THE SUBJECT FOR ABOUT 4 MONTHS NOW... I NEED HELP ON A PROGRAM IM WORKING ON THE INSTRUCTIONS FOLLOW....
WRITE A PROGRAM TO READ 3 NUMBERS FROM AN INPUT (IN.TXT) FILE (1,-5,6), THESE ARE COEFFICIENTS OF A QUADRATIC EQUATION. YOUR JOB IS TO USE THE QUADRATIC FORMULA AND FIND THE ROOTS OF THIS EQUATION. PRINT THE ROOTS AND OUTPUT THE FILE (OUTPUT.TXT)
FORMULA TO FIND ROOTS X = -b+(-)(open square root)b^2-4ac DIVIDED BY 2a
Keep in mind that B^2 - 4ac <0 you have to imaginairy solution
if b^2-4ac = 0 you have one real solution
and if b^2-4ac >0 then you have two real solutions
YOUR FUNCTION HEADER SHOULD LOOK LIKE
VOID ROOTS (INT A, INT B, INT C, INT & r1, int & r2)
Nothing lool... i am so lost....
i need a model program for this so i can make several that follow the same format and can help me visually learn it.
I tried starting it but realized i was doing it all wrong
Help would be greatley appreciated
#include <cmath> //This might help later.
void roots(int A, int B, int C, int& r1, int& r2)
{
int squirt = B*B - 4*A*C;
if (squirt < 0)
std::cerr << "Imaginary solution. \nThis function cannot handle these because you demanded ints instead of complex<int>s to be the types of r1 and r2.";
elseif (squirt = 0)
{
//Code here.
}
elseif (squirt > 0)
{
//Code here. Remember to account for the +/-!
}
}
I left out the juicy parts of the implementation for you to deal with. :P
lol ok i implemented what i could and got a world of errors!
if you would help me write the whole thing it would be greatly appreciated
i will master c++!! just gimme like 5 months lol