QBasic Programming

Solve a quadratic equation ax2+bx+c=0 on the basis of the coefficient values a, b, and c

REM SOLVE A QUADRATIC EQUATION
CLS
INPUT "ENTER VALUE FOR A"; A
INPUT "ENTER VALUE FOR B"; B
INPUT "ENTER VALUE FOR C"; C
D = (B * B - 4 * A * C) ^ (1 / 2)
X = (-B + D) / 2 * A
Y = (-B - D) / 2 * A
PRINT "SOLUTION OF QUADRATIC EQUATION ARE"; X; Y
END
USING SUB PROCEDURE
DECLARE SUB EQUATION (A, B, C)
CLS
INPUT "ENTER VALUE FOR A"; A
INPUT "ENTER VALUE FOR B"; B
INPUT "ENTER VALUE FOR C"; C
CALL EQUATION(A, B, C)
END
SUB EQUATION (A, B, C)
D = (B * B - 4 * A * C) ^ (1 / 2)
X = (-B + D) / 2 * A
Y = (-B - D) / 2 * A
PRINT "SOLUTION OF QUADRATIC EQUATION ARE"; X; Y
END SUB
USING FUNCTION PROCEDURE
DECLARE FUNCTION EQUATION (A, B, C)
COMMON SHARED X
CLS
INPUT "ENTER VALUE FOR A"; A
INPUT "ENTER VALUE FOR B"; B
INPUT "ENTER VALUE FOR C"; C
PRINT "SOLUTION OF QUADRATIC EQUATION ARE"; X; EQUATION(A, B, C)
END
FUNCTION EQUATION (A, B, C)
D = (B * B - 4 * A * C) ^ (1 / 2)
X = (-B + D) / 2 * A
Y = (-B - D) / 2 * A
EQUATION =Y
END FUNCTION

An organization pays its employees allowance at the rate of 10% of basic salary. WAP to input the salary of the employees and calculate the allowances (Prev Lesson)
(Next Lesson) WAP to input any number and check whether the given no. is divisible by 5 or not
Back to QBasic Programming

No Comments

Post a Reply

Course Curriculum

error: Content is protected !!