QBasic Programming

WAP to enter any 15 numbers and display only those numbers which are divisible by 5

CLS
DIM N(15)
FOR I = 1 TO 15
INPUT "ENTER THE NUMBERS"; N(I)
NEXT I
PRINT "THE NUMBERS WHICH ARE DIVISIBLE BY 5 ARE"
FOR I = 1 TO 15
IF N(I) MOD 5 = 0 THEN PRINT N(I)
NEXT I
END

USING SUB PROCEDURE
DECLARE SUB DIVISIBLE (N( ))
CLS
DIM N(15)
FOR I = 1 TO 15
INPUT "ENTER THE NUMBERS"; N(I)
NEXT I
CALL DIVISIBLE (N ( ))
END
SUB DIVISIBLE (N ( ))
PRINT "THE NUMBERS WHICH ARE DIVISIBLE BY 5 ARE"
FOR I = 1 TO 15
IF N(I) MOD 5 = 0 THEN PRINT N(I)
NEXT I
END SUB

USING FUNCTION PROCEDURE
DECLARE FUNCTION DIVISIBLE (N( ))
CLS
DIM N(15)
FOR I = 1 TO 15
INPUT "ENTER THE NUMBERS"; N(I)
NEXT I
D = DIVISIBLE(N())
END

FUNCTION DIVISIBLE (N())
PRINT "THE NUMBERS DIVISIBLE BY 5 ARE";
FOR I = 1 TO 15
IF N(I) MOD 5 = 0 THEN PRINT N(I)
NEXT I

END FUNCTION

Input the age of a person and find out whether the person is eligible to vote or not. [age >=18] (Prev Lesson)
(Next Lesson) WAP to enter any 15 numbers and display only those numbers which are divisible by 5 and 7
Back to QBasic Programming

No Comments

Post a Reply

Course Curriculum

error: Content is protected !!