diff --git a/Assignment 5/main.c b/Assignment 5/main.c index 6b474e0..925eb82 100644 --- a/Assignment 5/main.c +++ b/Assignment 5/main.c @@ -10,8 +10,7 @@ int gcd (int p, int q) { int r; - while (q > 0) /* Loops until the remainder is 0 */ - { + while (q > 0){ /* Loops until the remainder is 0 */ r = p%q; /* Calculate remainder */ p=q; /* Storing the value of q in p */ q=r; /* Setting q to the value of the remainder to calculate new remainder in the next iteration */ diff --git a/Assignment 6/abc.c b/Assignment 6/abc.c new file mode 100644 index 0000000..06d5ba2 --- /dev/null +++ b/Assignment 6/abc.c @@ -0,0 +1,13 @@ +/* + * Student: S.K. Soekhlal + * Number: 4860632 + * Assignment: 3.4 + */ + +#include +#include +#include + +int discriminant(){ + +} \ No newline at end of file diff --git a/Assignment 6/interface.c b/Assignment 6/interface.c new file mode 100644 index 0000000..19ab64e --- /dev/null +++ b/Assignment 6/interface.c @@ -0,0 +1,45 @@ +/* + * Student: S.K. Soekhlal + * Number: 4860632 + * Assignment: 3.4 + */ + +#include + +void abc(); + +int a,b,c; + +extern double x1real, x2real, ximag; + +static void get_parameters(){ + scanf("%d",&a); + scanf("%d",&b); + scanf("%d",&c); +} + +void print_solution(){ + printf("The roots of %dx^2 + %dx + %d are :\n", a,b,c); + if(ximag < 1e-99){ + if(x1real == x2real){ + printf("x = %.4f, x2 = %.4f\n",x1real,x2real); + } + else{ + printf( "x1 = %.4f, x2 = %.4f\n" ,x1real,x2real); + } + } + else{ + printf("x1 = %.4f+%.4fi , x2 = %.4f-%.4f1\n",x1real,ximag); + } +} + +int main(){ + int runs, run; + scanf("%d", &runs); + for (run = 0; run < runs; run++){ + get_parameters(); + abc(); + print_solution(); + } + return 0; +} \ No newline at end of file