Advertisement
Guest User

Untitled

a guest
May 31st, 2017
46
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <stdlib.h>
  2. #include <math.h>
  3. #include <stdio.h>
  4.  
  5. int main(){
  6.    
  7.     //Global Values
  8.     double a, b, c, deno, bsfac;
  9.     double sqbsfac;
  10.    
  11.     //Positive
  12.     double POSx, POSnumerator;
  13.    
  14.     //Negative
  15.     double NEGx, NEGnumerator, NEGb;
  16.  
  17.     //Title
  18.     printf("Quadriatic Formula Solver\n");
  19.     printf("-by Brendan\n\n");
  20.    
  21.     //Grab Values
  22.     printf("Please enter the value of a, b, and c, respectively (with spaces):");
  23.     scanf("%lf%", &a);
  24.     scanf("%lf%", &b);
  25.     scanf("%lf%", &c);
  26.     //printf("Ok, hit any key to continue with the values: \nA = %lf%\nB = %lf%\nC = %lf%\n", a, b, c);
  27.    
  28.     //Compute
  29.     deno = 2*a;
  30.     NEGb = 0-b;
  31.     bsfac = (b*b) - (4*a*c);
  32.     sqbsfac = sqrt(bsfac);
  33.    
  34.     //Positive Compute
  35.     POSnumerator = NEGb + sqbsfac;
  36.     POSx = POSnumerator / deno;
  37.    
  38.     //Negative Compute
  39.     NEGnumerator = NEGb - sqbsfac;
  40.     NEGx = NEGnumerator / deno;
  41.    
  42.     //Return results
  43.     printf("The two possible values for \"X\" are: \n\n");
  44.     printf("X1 is:     %lf%\n", NEGx);
  45.     printf("X2 is:     %lf%\n\n", POSx);
  46.    
  47.     //Crap lol    
  48.     system("pause");
  49. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement