36 lines
1.3 KiB
C
36 lines
1.3 KiB
C
#include <stdio.h> //printf and shit
|
|
#include <math.h> //website told me to use fabs for floating point absolute value. this also has sqrt (sqrt for somereason needs the -lm compile flag)
|
|
#include <stdlib.h> //this has atoi which i forgot to incled but it still combiled idk dont @ me
|
|
|
|
int main( int argc, char *argv[] ) { //yoinked from the internet argc is number of args and argv is a "array of arguments"
|
|
|
|
int a, b, c; //uhhhhhh how to ascii to float
|
|
|
|
float deter, plusans, minusans;
|
|
|
|
if (argc != 4) {
|
|
puts("please provide a b c");
|
|
return 0; //idk if this is how i should return an error idk @quantum rip my code to shreads
|
|
}
|
|
|
|
a = atoi(argv[1]); //mmmm yes the atoi is made out of atoi
|
|
b = atoi(argv[2]); //mmmm yes the atoi is made out of atoi
|
|
c = atoi(argv[3]); //mmmm yes the atoi is made out of atoi
|
|
|
|
printf("Got: %dx²+%dx+%d\n", a, b, c); //wow this looks like ass
|
|
|
|
deter = (b*b)-(4*a*c);
|
|
//deter = 12f;
|
|
printf("Deter = %f\n", deter);
|
|
if (deter < 0) {
|
|
puts("deter is negitve this will result in a imaginary number");
|
|
return 0;
|
|
}
|
|
|
|
plusans = (-b + sqrt(deter))/(2*a); //pemdas is cringe
|
|
printf("Plusans = %f\n", plusans);
|
|
minusans = (-b - sqrt(deter))/(2*a); //pemdas is cringe
|
|
printf("Minusans = %f\n", minusans);
|
|
|
|
return 0;
|
|
}
|