Half of assignment 6
This commit is contained in:
		
							
								
								
									
										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;
 | 
			
		||||
}
 | 
			
		||||
		Reference in New Issue
	
	Block a user