Presentation is loading. Please wait.

Presentation is loading. Please wait.

Quadratic Equations. PROGRAM QuadraticEquations_1 IMPLICIT NONE REAL A, B, C, Discriminant, Root_1, Root_2 ! Get the coefficients PRINT *, "Enter the.

Similar presentations


Presentation on theme: "Quadratic Equations. PROGRAM QuadraticEquations_1 IMPLICIT NONE REAL A, B, C, Discriminant, Root_1, Root_2 ! Get the coefficients PRINT *, "Enter the."— Presentation transcript:

1 Quadratic Equations

2 PROGRAM QuadraticEquations_1 IMPLICIT NONE REAL A, B, C, Discriminant, Root_1, Root_2 ! Get the coefficients PRINT *, "Enter the coefficients of the quadratic equation:" READ *, A, B, C ! Calculate the discriminant Discriminant = B**2 - 4.0*A*C IF (Discriminant >= 0) THEN Discriminant = SQRT(Discriminant) Root_1 = (-B + Discriminant) / (2.0 * A) Root_2 = (-B - Discriminant) / (2.0 * A) PRINT *, "The roots are", Root_1, Root_2 ELSE PRINT *, "Discriminant is", Discriminant PRINT *, "There are no real roots" END IF END PROGRAM QuadraticEquations_1

3 Logical Circuits Sum = (A + B). (A. B) Carry = A. B +.

4 Logical Circuits Sum = (A + B). (A. B) Carry = A. B +. Sum = (A.OR. B).AND..NOT. (A.AND. B) Carry = A.AND. B

5 PROGRAM Half_Adder !----------------------------------------------------------------------- ! Program to calculate the outputs from a logical circuit that ! represents a binary half-adder. Variables used are: ! A, B : the two logical inputs to the circuit ! Sum, Carry : the two logical outputs ! ! Input: The two logical inputs A and B ! Output: The two logical outputs Sum and Carry, which represent the ! sum and carry that result when the input values are added !----------------------------------------------------------------------- IMPLICIT NONE LOGICAL :: A, B, Sum, Carry PRINT *, "Enter logical inputs A and B:" READ *, A, B Sum = (A.OR. B).AND..NOT. (A.AND. B) Carry = A.AND. B PRINT *, "Carry, Sum =", Carry, Sum END PROGRAM Half_Adder

6 IF Construct

7 CASE Construct


Download ppt "Quadratic Equations. PROGRAM QuadraticEquations_1 IMPLICIT NONE REAL A, B, C, Discriminant, Root_1, Root_2 ! Get the coefficients PRINT *, "Enter the."

Similar presentations


Ads by Google