Stuff, Things

This commit is contained in:
Shaquille Soekhlal
2019-10-11 22:34:52 +02:00
parent 7c6fcb78b3
commit 957e7d3ed0
5 changed files with 122 additions and 7 deletions

View File

@ -1,13 +1,33 @@
/*
* Student: S.K. Soekhlal
* Number: 4860632
* Assignment: 3.4
* Assignment: 3.6
*/
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
int discriminant(){
double x1real,x2real,ximag;
extern int a,b,c; /*Variables stored in another file*/
static float discriminant(){
return (pow(b,2)-(4*a*c)); /*Calculate Discriminant */
}
void abc(){
float D = discriminant();
if (D>0){
x1real = ((-b+sqrt(D))/(2.0*a));
x2real = ((-b-sqrt(D))/(2.0*a));
ximag = 0;
}
else if(D<0){
x1real = -b/(2.0*a);
x2real = x1real;
ximag = (sqrt(-D)/(2.0*a));
}
else{
x1real = -b/(2.0*a);
x2real = x1real;
ximag = 0;
}
}