Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdlib.h>
- #include <math.h>
- #include <stdio.h>
- int main(){
- //Global Values
- double a, b, c, deno, bsfac;
- double sqbsfac;
- //Positive
- double POSx, POSnumerator;
- //Negative
- double NEGx, NEGnumerator, NEGb;
- //Title
- printf("Quadriatic Formula Solver\n");
- printf("-by Brendan\n\n");
- //Grab Values
- printf("Please enter the value of a, b, and c, respectively (with spaces):");
- scanf("%lf%", &a);
- scanf("%lf%", &b);
- scanf("%lf%", &c);
- //printf("Ok, hit any key to continue with the values: \nA = %lf%\nB = %lf%\nC = %lf%\n", a, b, c);
- //Compute
- deno = 2*a;
- NEGb = 0-b;
- bsfac = (b*b) - (4*a*c);
- sqbsfac = sqrt(bsfac);
- //Positive Compute
- POSnumerator = NEGb + sqbsfac;
- POSx = POSnumerator / deno;
- //Negative Compute
- NEGnumerator = NEGb - sqbsfac;
- NEGx = NEGnumerator / deno;
- //Return results
- printf("The two possible values for \"X\" are: \n\n");
- printf("X1 is: %lf%\n", NEGx);
- printf("X2 is: %lf%\n\n", POSx);
- //Crap lol
- system("pause");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement