Recently, I was assigned a program that needs to be able to do the quadratic equation. I use this code
X = ((B*B) - 4*(A*C));
X1 = (sqrt(X));
X2 = 0-X1;
X3 = X1/(2*A);
X4 = X2/(2*A);
Y = (-B + X3);
Z = (-B - X3);
Y1 = (-B + X4);
Z1 = (-B - X4);
printf("\nResult from adding the + roots:\t\t\t%f", Y);
printf("\nResult from minusing the + roots:\t\t%f", Z);
if (X1 > 0){
printf("\nResult from adding the - roots:\t\t\t%f",Y1);
printf("\nResult from minusing the - roots:\t\t%f",Z1);}
I'm not sure if that's even close to being right, but From my PoV it looks alright but, I haven't taken this subject for that long.. If anyone could please correct anything that looks wrong.. >_<.. Whenever I get like.. negative values or imaginaries It woudl do somethign like 1.#J or 1.#INFOOO depending on how many variables I set it for..
These are my declarations.. i'm not sure if this helps, but i hope it does >_<...
#include <stdio.h>
#include <conio.h>
#include <math.h>
char back;
int choice;
float A, B, C, X, X1, X2, X3, X4, Y, Y1, Z, Z1;