Write a program in GW-BASIC to assign two numbers to two variables. Calculate and display the sum and difference of the two numbers with messages.
Answers
Answer:
1. Enter any two numbers and display its sum.
REM PROGRAM TO DISPLAY SUM OF TWO NUMBERS
CLS
INPUT “ENTER FIRST NUMBER”; A
INPUT “ENTER SECOND NUMBER”; B
S = A + B
PRINT “SUM 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 + B
PRINT “SUM 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)
Explanation:
CLS
INPUT “ENTER FIRST NUMBER”; A
INPUT “ENTER SECOND NUMBER”; B
S = SUM(A, B)
PRINT “SUM OF TWO NUMBERS”; S
END
FUNCTION SUM (A, B)
SU = A + B
SUM = SU
END FUNCTION
2. Enter any two numbers and display its difference.
REM PROGRAM TO DISPLAY DIFFERENCE OF TWO NUMBERS
CLS
INPUT “ENTER FIRST NUMBER”; A
INPUT “ENTER SECOND NUMBER”; B
D = A - B
PRINT “DIFFERENCE OF TWO NUMBERS”; D
END
USING SUB PROCEDURE
DECLARE SUB DIFF (A, B)
CLS
INPUT “ENTER FIRST NUMBER”; A
INPUT “ENTER SECOND NUMBER”; B
CALL DIFF(A, B)
END
Answer:
Write a program in GW-BASIC
Explanation:
Write a Program to Print even numbers from 1 to 40.
Program:
10 CLS
20 FOR B = 2 TO 40 STEP 2
30 PRINT B
40 NEXT B
50 END
Algorithm
Step 1 START
Step 2 STORAGE B=2
Step 3 DECISION IS B<= 40 IF
NOT THEN GO TO STEP 7
Step 4 COMPUTE B=B+2
Step 5 PRINT
STEP 6 GOTO STEP 3
Step 7 END
Algorithm
Step 1 START
Step 2 INPUT L , W
Step 3 COMPUTE AREA= L * W
Step 4 PRINT AREA
Step 5 END
Enter any two numbers and display its sum.
REM PROGRAM TO DISPLAY SUM OF TWO NUMBERS
CLS
INPUT “ENTER FIRST NUMBER”; A
INPUT “ENTER SECOND NUMBER”; B
S = A + B
PRINT “SUM 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 + B
PRINT “SUM 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)
Explanation:
CLS
INPUT “ENTER FIRST NUMBER”; A
INPUT “ENTER SECOND NUMBER”; B
S = SUM(A, B)
PRINT “SUM OF TWO NUMBERS”; S
END
FUNCTION SUM (A, B)
SU = A + B
SUM = SU
END FUNCTION
Enter any two numbers and display its difference.
REM PROGRAM TO DISPLAY DIFFERENCE OF TWO NUMBERS
CLS
INPUT “ENTER FIRST NUMBER”; A
INPUT “ENTER SECOND NUMBER”; B
D = A - B
PRINT “DIFFERENCE OF TWO NUMBERS”; D
END
USING SUB PROCEDURE
DECLARE SUB DIFF (A, B)
CLS
INPUT “ENTER FIRST NUMBER”; A
INPUT “ENTER SECOND NUMBER”; B
CALL DIFF(A, B)
END
The GW-BASIC command-line environment has commands to RUN , LOAD , SAVE , LIST the current program, or quit to the operating SYSTEM ; these commands can also be used as program statements. There is little support for structured programming in GW-BASIC.
Write a program in GW-BASIC
https://brainly.in/question/42957344
write a program in Gw basic to calculate and display the monthly salary of a worker working for a company .
https://brainly.in/question/34070231
#SPJ2