Half of assignment 6
This commit is contained in:
parent
395564a57a
commit
1f11ed2910
@ -10,8 +10,7 @@
|
|||||||
int gcd (int p, int q)
|
int gcd (int p, int q)
|
||||||
{
|
{
|
||||||
int r;
|
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 */
|
r = p%q; /* Calculate remainder */
|
||||||
p=q; /* Storing the value of q in p */
|
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 */
|
q=r; /* Setting q to the value of the remainder to calculate new remainder in the next iteration */
|
||||||
|
13
Assignment 6/abc.c
Normal file
13
Assignment 6/abc.c
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
/*
|
||||||
|
* Student: S.K. Soekhlal
|
||||||
|
* Number: 4860632
|
||||||
|
* Assignment: 3.4
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include<stdio.h>
|
||||||
|
#include<stdlib.h>
|
||||||
|
#include<math.h>
|
||||||
|
|
||||||
|
int discriminant(){
|
||||||
|
|
||||||
|
}
|
45
Assignment 6/interface.c
Normal file
45
Assignment 6/interface.c
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
/*
|
||||||
|
* Student: S.K. Soekhlal
|
||||||
|
* Number: 4860632
|
||||||
|
* Assignment: 3.4
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include<stdio.h>
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user