i made the quadratic formula
what a suprise @quantum thooooommmmmaaasss it dont work plez help it gives wrong answer
This commit is contained in:
parent
39e75a6b2b
commit
33218f0960
3 changed files with 42 additions and 2 deletions
|
@ -9,7 +9,7 @@ int main( int argc, char *argv[] ) { //yoinked from the internet argc is number
|
|||
return 0; //idk if this is how i should return an error idk @quantum rip my code to shreads
|
||||
}
|
||||
|
||||
x = atoi(argv[1]);
|
||||
x = atoi(argv[1]); //mmmm yes the atoi is made out of atoi
|
||||
|
||||
if(x == 0){
|
||||
puts("uhhhh you entered 0 this wont end");
|
||||
|
@ -21,7 +21,7 @@ int main( int argc, char *argv[] ) { //yoinked from the internet argc is number
|
|||
|
||||
|
||||
while(x != 1){ //while x is not true i think
|
||||
printf("%d\n",x );
|
||||
printf("%d\n",x ); //shit like this was difficualt in asm because i had to preserve all my registers
|
||||
if(x & 1 == 1){ //if x is odd
|
||||
x = (3 * x) + 1;
|
||||
}
|
||||
|
|
BIN
a.out
BIN
a.out
Binary file not shown.
40
quadratic.c
Normal file
40
quadratic.c
Normal file
|
@ -0,0 +1,40 @@
|
|||
#include <stdio.h> //printf and shit
|
||||
#include <math.h> //website told me to use fabs for floating point absolute value
|
||||
|
||||
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 x, deter, plusans, minusans;
|
||||
|
||||
|
||||
const float pi = 3.1415926535897932384626338f;
|
||||
|
||||
printf("%f\n", pi); //did i print pi corectly???
|
||||
|
||||
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^2)-(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;
|
||||
}
|
Loading…
Reference in a new issue