![]() |
C++ Help - Printable Version +- [TC] Gaming Forums (https://forum.city-driving.co.uk) +-- Forum: Community Area (/forumdisplay.php?fid=14) +--- Forum: Technology Area (/forumdisplay.php?fid=82) +---- Forum: Tech Support (/forumdisplay.php?fid=85) +---- Thread: C++ Help (/showthread.php?tid=19915) |
C++ Help - FolloweR - 2015-10-12 15:49 Eyo people, I need some help with C++ based stuff. I have to make a problem that solves a biquadratic equation (ax4 +bx2+c=0), but I can only figure out how to make a program that solves a quadratic equation (ax2+bx+c=0). If someone is willing to help me how to make a program which solves a biquadratic equation, I would be very thankful. P.S. If you need it, that's the code for the program that solves a quadratic equation. ![]() RE: C++ Help - Barney - 2015-10-12 16:12 oh god... didnt see this crap for a long time. dont u basically just need to do a substitution. replace x2 with y. than u get a quadratic equation what u r alrdy able to solve. in the end you re-substitute. thats all i remember lol xD also format your code properly. will get messy longterm. tab all lines after a bracket. RE: C++ Help - FolloweR - 2015-10-12 16:25 I tried doing that, but couldn't manage to get it working. I was able to find y1,y2, but then couldn't re-substitute because it was showing some errors. RE: C++ Help - Gutholz - 2015-10-12 16:56 post the non-working code (as text, not picture) plus the errors RE: C++ Help - FolloweR - 2015-10-12 17:44 Hmm, I thought it would work with that, but I guess I've done something wrong again.. I tried substituting y=x*x, but it said x isn't initialized. ![]() That's the code: Code: #include <iostream> RE: C++ Help - Gutholz - 2015-10-12 19:37 It prints x1=NAN (not a number) because y1 is negative and sqrt() function can not calculate squareroot of negative numbers. In first post you wrote: Quote:ax4 +bx2+c=0I assume you meant: a(x^4) +b(x^2)+c=0 ? With the input from your screenshot: a=1 b=4 c=1 The graph looks like this: ![]() => This function has no solution. Try entering some other values, plot the graph, and compare, might be that your program is already correct? RE: C++ Help - FolloweR - 2015-10-13 16:07 Okay, I've finally done it. Figured out a way to use as many if and else's as possible, and it seems to work. That's the code: Code: #include <iostream> Cheers for the help guys! |