Saturday, October 22, 2016

Qbasic Program: Traingle



152. WAP to input three sides of a triangle and determine whether a triangle can be formed or not.

CLS
INPUT “ENTER THREE SIDES OF A TRIANGLE”; A,B,C
IF (A + B) > C AND (B + C) > A AND (A + C) > B THEN
PRINT “THE TRIANGLE CAN BE FORMED”
ELSE
PRINT “THE TRIANGLE CANNOT  BE FORMED”
END IF
END

USING SUB PROCEDURE

DECLARE SUB CHECK (A, B, C)
CLS
INPUT “ENTER THREE SIDES OF A TRIANGLE”; A,B,C
CALL CHECK (A, B, C)
END

SUB CHECK (A, B, C)
IF (A + B) > C AND (B + C) > A AND (A + C) > B THEN
PRINT “THE TRIANGLE CAN BE FORMED”
ELSE
PRINT “THE TRIANGLE CANNOT  BE FORMED”
END IF
END SUB
USING FUNCTION PROCEDURE
DECLARE FUNCTION CHECK$ (A, B, C)
CLS
INPUT “ENTER THREE SIDES OF A TRIANGLE”; A,B,C
PRINT CHECK$ (A,B,C)
END
FUNCTION CHECK$ (A, B, C)
IF (A + B) > C AND (B + C) > A AND (A + C) > B THEN
CHECK$ =  “THE TRIANGLE CAN BE FORMED”
ELSE
CHECK$ = “THE TRIANGLE CANNOT  BE FORMED”
END IF
END FUNCTION

153. WAP to input three sides of a triangle and determine whether a triangle is right angled triangle or not.
CLS
INPUT “ENTER HEIGHT, BASE AND PERPENDICULAR”; H, B, P
IF H ^ 2 = (B ^ 2 + P ^ 2) THEN
PRINT “IT IS A RIGHT ANGLED TRIANGLE”
ELSE
PRINT “IT IS NOT A RIGHT ANGLED TRIANGLE”
END IF
END
USING SUB PROCEDURE

DECLARE SUB CHECK (H, B, P)
CLS
INPUT “ENTER HEIGHT, BASE AND PERPENDICULAR”; H, B, P
CALL CHECK (H, B, P)
END
SUB CHECK (H, B, P)
IF H ^ 2 = (B ^ 2 + P ^ 2) THEN
PRINT “IT IS A RIGHT ANGLED TRIANGLE”
ELSE
PRINT “IT IS NOT A RIGHT ANGLED TRIANGLE”
END IF
END SUB

USING FFUNCTION PROCEDURE

DECLARE FUNCTION CHECK$ (H, B, P)
CLS
INPUT “ENTER HEIGHT, BASE AND PERPENDICULAR”; H, B, P
PRINT CHECK$ (H, B, P)
END

FUNCTION CHECK$ (H, B, P)
IF H ^ 2 = (B ^ 2 + P ^ 2) THEN
CHECK$  = “IT IS A RIGHT ANGLED TRIANGLE”
ELSE
CHECK$  = “IT IS NOT A RIGHT ANGLED TRIANGLE”
END IF
END FUNCTION

154. WAP to input three angles of a triangle and determine whether a triangle is right angled triangle or not.

CLS
INPUT “ENTER THREE ANGLES OF A TRIANGLE”; A,B,C
IF A = 90 OR B = 90 OR C = 90 THEN
PRINT “IT IS A RIGHT ANGLED TRIANGLE”
ELSE
PRINT “IT IS NOT A RIGHT ANGLED TRIANGLE”
END IF
END

USING SUB PROCEDURE
DECLARE SUB CHECK (A, B, C)
CLS
INPUT “ENTER THREE SIDES OF A TRIANGLE”; A,B,C
CALL CHECK (A, B, C)
END
SUB CHECK (A, B, C)
IF A = 90 OR B = 90 OR C = 90 THEN
PRINT “IT IS A RIGHT ANGLED TRIANGLE”
ELSE
PRINT “IT IS NOT A RIGHT ANGLED TRIANGLE”
END IF
END SUB

USING FUNCTION PROCEDURE

DECLARE FUNCTION CHECK$ (A, B, C)
CLS
INPUT “ENTER THREE SIDES OF A TRIANGLE”; A,B,C
PRINT CHECK$ (A,B,C)
END
FUNCTION CHECK$ (A, B, C)
IF A = 90 OR B = 90 OR C = 90 THEN
CHECK$ =  “IT IS A RIGHT ANGLED TRIANGLE”
ELSE
CHECK$ =  “IT IS NOT A RIGHT ANGLED TRIANGLE”
END IF
END FUNCTION

155. WAP to input three sides of a triangle and determine whether a triangle is equilateral triangle or
not.

CLS
INPUT “ENTER THREE SIDES OF A TRIANGLE”; A,B,C
IF A = B AND B = C THEN
PRINT “IT IS A EQUILATERAL TRIANGLE”
ELSE
PRINT “IT IS NOT A EQUILATERAL TRIANGLE”
END IF
USING SUB PROCEDURE

DECLARE SUB CHECK (A, B, C)
CLS
INPUT “ENTER THREE SIDES OF A TRIANGLE”; A,B,C
CALL CHECK (A, B, C)
END

SUB CHECK (A, B, C)
IF A = B AND B = C THEN
PRINT “IT IS A EQUILATERAL TRIANGLE”
ELSE
PRINT “IT IS NOT A EQUILATERAL TRIANGLE”
END IF
END SUB

USING FUNCTION PROCEDURE

DECLARE FUNCTION CHECK$ (A, B, C)
CLS
INPUT “ENTER THREE SIDES OF A TRIANGLE”; A,B,C
PRINT CHECK$ (A,B,C)
END

FUNCTION CHECK$ (A, B, C)
IF A = B AND B = C THEN
CHECK$ =  “IT IS A EQUILATERAL TRIANGLE”
ELSE
CHECK$ = “IT IS NOT A EQUILATERAL TRIANGLE”
END IF
END FUNCTION



156. WAP to input three sides of a triangle and determine whether a triangle is equilateral, isosceles or scalene triangle or not.

CLS
INPUT “ENTER THREE SIDES OF A TRIANGLE”; A,B,C
IF A = B AND B = C THEN
PRINT “IT IS A EQUILATERAL TRIANGLE”
ELSEIF A = B OR B = C OR C = A THEN
PRINT “IT IS ISOSCELES TRIANGLE”
ELSEIF A < > B AND B < > C THEN
PRINT “ IT IS A SCALENE TRIANGLE”
END IF
END

USING SUB PROCEDURE

DECLARE SUB CHECK (A, B, C)
CLS
INPUT “ENTER THREE SIDES OF A TRIANGLE”; A,B,C
CALL CHECK (A, B, C)
END

SUB CHECK (A, B, C)
IF A = B AND B = C THEN
PRINT “IT IS A EQUILATERAL TRIANGLE”
ELSEIF A = B OR B = C OR C = A THEN
PRINT “IT IS ISOSCELES TRIANGLE”
ELSEIF A < > B AND B < > C THEN
PRINT “ IT IS A SCALENE TRIANGLE”
END IF
END SUB
USING FUNCTION PROCEDURE
DECLARE FUNCTION CHECK$ (A, B, C)
CLS
INPUT “ENTER THREE SIDES OF A TRIANGLE”; A,B,C
PRINT CHECK$ (A,B,C)
END

FUNCTION CHECK$ (A, B, C)
IF A = B AND B = C THEN
CHECK$ = “IT IS A EQUILATERAL TRIANGLE”
ELSEIF A = B OR B = C OR C = A THEN
CHECK$ =  “IT IS ISOSCELES TRIANGLE”
ELSEIF A < > B AND B < > C THEN
CHECK$ =  “ IT IS A SCALENE TRIANGLE”
END IF
END FUNCTION

2 comments:

  1. Excellent site and thanks a lot
    I found very useful for SEE students
    Once again tq

    ReplyDelete