QBasic Programming

Display sum of half of any two given numbers

REM PROGRAM TO DISPLAY SUM OF HALF OF ANY TWO GIVEN NUMBERS
CLS
INPUT “ENTER FIRST NUMBER”; A
INPUT “ENTER SECOND NUMBER”; B
S = A / 2 + B / 2
PRINT “SUM OF HALF OF TWO NUMBERS”; S
END

USING SUB PROCEDURE
DECLARE SUB SUM (A, B)
CLS
INPUT “ENTER FIRST NUMBER”; A
INPUT “ENTER SECOND NUMBER”; B
CALL SUM(A, B)
END

SUB SUM (A, B)
S = A / 2 + B / 2
PRINT “SUM OF HALF OF TWO NUMBERS”; S
END SUB

USING FUNCTION PROCEDURE
DECLARE FUNCTION SUM (A, B)
CLS
INPUT “ENTER FIRST NUMBER”; A
INPUT “ENTER SECOND NUMBER”; B
S = SUM(A, B)
PRINT “SUM OF HALF OF TWO NUMBERS”; S
END

FUNCTION SUM (A, B)
SU =  A / 2 + B / 2
SUM = SU
END FUNCTION

Enter any three numbers and display its sum, product and average (Prev Lesson)
(Next Lesson) Input n number and print the sum of first n natural 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 !!