QBasic Programming

WAP to enter any 10 numbers and find the sum of odd numbers

CLS
FOR I = 1 TO 10
INPUT "ENTER THE NUMBERS"; N(I)
IF N(I) MOD 2 = 1 THEN S = S + N(I)
NEXT I
PRINT "SUM OF 10 ODD NUMBERS"; S
END
USING SUB PROCEDURE
DECLARE SUB SUM (N( ))
CLS
FOR I = 1 TO 10
INPUT "ENTER THE NUMBERS"; N(I)
NEXT I
CALL SUM(N( ))
END
SUB SUM (N())
FOR I = 1 TO 10
IF N(I) MOD 2 = 1 THEN S = S + N(I)
NEXT I
PRINT "SUM OF 10 ODD NUMBERS"; S
END SUB

USING FUNCTION PROCEDURE
DECLARE FUNCTION SUM (N( ))
CLS
FOR I = 1 TO 10
INPUT "ENTER THE NUMBERS"; N(I)
NEXT I
PRINT "SUM OF 10 ODD NUMBERS"; SUM(N( ))
END

FUNCTION SUM (N())
FOR I = 1 TO 10
IF N(I) MOD 2 = 1 THEN S = S + N(I)
NEXT I
SUM = S
END FUNCTION

WAP to enter any 10 numbers and find the sum of numbers (Prev Lesson)
(Next Lesson) WAP to enter any 10 numbers and find the sum of even numbers
Back to QBasic Programming

No Comments

Post a Reply

Course Curriculum

error: Content is protected !!