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
Notice: compact(): Undefined variable: limits in /home/bhimgautam34/public_html/wp-includes/class-wp-comment-query.php on line 853

Notice: compact(): Undefined variable: groupby in /home/bhimgautam34/public_html/wp-includes/class-wp-comment-query.php on line 853

No Comments

Post a Reply

Course Curriculum

error: Content is protected !!