WRITE A QBASIC PROGRAM TO DISPLAY SUM OF ALL NATURAL NUMBERS BETWEEN 1 AND 100.

WRITE A QBASIC PROGRAM TO DISPLAY SUM OF ALL NATURAL NUMBERS BETWEEN 1 AND 100.

QBASIC PROGRAM TO DISPLAY SUM OF ALL NATURAL NUMBERS BETWEEN 1 AND 100.  

Here in this Qbasic program, we will display the sum of all natural numbers from 1 to 100.

Solution

DECLARE SUB SERIES ( )
CLS
CALL SERIES
END

SUB SERIES
FOR I = 1 TO 100
PRINT I,
NEXT I
END SUB


WRITE A QBASIC PROGRAM TO SORT NUMBER IN DESCENDING ORDER

WRITE A QBASIC PROGRAM TO SORT NUMBER IN DESCENDING ORDER

 

DESCENDING OF 10 INPUT NUMBERS

How to arrange numbers in descending order in Qbasic

Here in this post, we will write a program to sort a list of 10 numbers in descending order.


Solution



CLS
DIM N(10)
FOR I = 1 TO 10
INPUT "ENTER THE NUMBERS"; N(I)
NEXT I
FOR I = 1 TO 10
FOR J = 1 TO 10 - I
IF N(J) < N(J + 1) THEN SWAP N(J), N(J + 1)
NEXT J
NEXT I
PRINT "NUMBERS ARRANGED IN DESCENDING ORDER"
FOR I = 1 TO 10
PRINT N(I)
NEXT I

END SUB

SORT NUMBER IN DESCENDING ORDER USING SUB PROCEDURE


DECLARE SUB SORT (N())
CLS
DIM N(10)
FOR I = 1 TO 10
INPUT "ENTER THE NUMBERS"; N(I)
NEXT I
CALL SORT(N())
PRINT "NUMBERS ARRANGED IN DESCENDING ORDER"
FOR I = 1 TO 10
PRINT N(I)
NEXT I
END


SUB SORT (N())
FOR I = 1 TO 10
FOR J = 1 TO 10 - I
IF N(J) < N(J + 1) THEN SWAP N(J), N(J + 1)
NEXT J
NEXT I

END SUB


WRITE A QBASIC PROGRAM TO SORT NUMBER IN ASCENDING ORDER

WRITE A QBASIC PROGRAM TO SORT NUMBER IN ASCENDING ORDER

 ASCENDING AND DESCENDING OF 10 INPUT NUMBERS

How to arrange numbers in ascending order in Qbasic

Here in this post, we will write a program to sort a list of 10 numbers in ascending order.


Solution



CLS
DIM N(10)
FOR I = 1 TO 10
INPUT "ENTER THE NUMBERS"; N(I)
NEXT I
FOR I = 1 TO 10
FOR J = 1 TO 10 - I
IF N(J) > N(J + 1) THEN SWAP N(J), N(J + 1)
NEXT J
NEXT I
PRINT "NUMBERS ARRANGED IN ASCENDING ORDER"
FOR I = 1 TO 10
PRINT N(I)
NEXT I

END SUB


SORT NUMBER ASCENDING  USING SUB PROCEDURE


DECLARE SUB SORT (N())
CLS
DIM N(10)
FOR I = 1 TO 10
INPUT "ENTER THE NUMBERS"; N(I)
NEXT I
CALL SORT(N())
PRINT "NUMBERS ARRANGED IN ASCENDING ORDER"
FOR I = 1 TO 10
PRINT N(I)
NEXT I
END


SUB SORT (N())
FOR I = 1 TO 10
FOR J = 1 TO 10 - I
IF N(J) > N(J + 1) THEN SWAP N(J), N(J + 1)
NEXT J
NEXT I

END SUB
WRITE A QBASIC PROGRAM DISPLAY VOLUME OF CYLINDER

WRITE A QBASIC PROGRAM DISPLAY VOLUME OF CYLINDER

QBASIC PROGRAM DISPLAY VOLUME OF CYLINDER

Solution

Display the volume of a cylinder.


REM PROGRAM TO DISPLAY VOLUME OF CYLINDER.
CLS
INPUT “ENTER RADIUS ”; R
INPUT “ENTER HEIGHT”; H
V = 3.14 * R ^ 2 * H
PRINT “VOLUME OF CYLINDER ”; V
END

DISPLAY VOLUME OF CYLINDER USING SUB PROCEDURE


DECLARE SUB VOLUME(R, H)
CLS
INPUT “ENTER RADIUS”; R
INPUT “ENTER HEIGHT”; H
CALL VOLUME(R, H)
END

SUB VOLUME (R, H)
V = 3.14 * R ^ 2 * H
PRINT “VOLUME OF CYLINDER ”; V
END SUB


DISPLAY VOLUME OF CYLINDER USING FUNCTION PROCEDURE


DECLARE FUNCTION VOLUME (R, H)
CLS
INPUT “ENTER RADIUS”; R
INPUT “ENTER HEIGHT”; H
PRINT “VOLUME OF CYLINDER ”; VOLUME(R, H)
END

FUNCTION VOLUME (R, H)
VOLUME = 3.14 * R ^ 2 * H
END FUNCTION
WRITE A QBASIC PROGRAM DISPLAY SURFACE AREA OF CYLINDER

WRITE A QBASIC PROGRAM DISPLAY SURFACE AREA OF CYLINDER

 A QBASIC PROGRAM DISPLAY SURFACE AREA OF CYLINDER

Solution


Display the total surface area of the cylinder.


REM PROGRAM TO DISPLAY TOTAL SURFACE AREA OF CYLINDER
CLS
INPUT “ENTER RADIUS ”; R
INPUT “ENTER HEIGHT”; H
A= 2 * 3.14 * R * (R + H)
PRINT “TOTAL SURFACE AREA OF CYLINDER “; A
END


DISPLAY SURFACE AREA OF CYLINDER USING SUB PROCEDURE


DECLARE SUB TSAREA (R, H)
CLS
INPUT “ENTER RADIUS”; R
INPUT “ENTER HEIGHT”; H
CALL TSAREA(R, H)
END

SUB TSAREA (R, H)
A= 2 * 3.14 * R * (R + H)
PRINT “TOTAL SURFACE AREA OF CYLINDER “; A
END SUB

DISPLAY SURFACE AREA OF CYLINDER USING FUNCTION PROCEDURE


DECLARE FUNCTION TSAREA (R, H)
CLS
INPUT “ENTER RADIUS”; R
INPUT “ENTER HEIGHT”; H
PRINT “TOTAL SURFACE AREA OF CYLINDER”; TSAREA(R, H)
END

FUNCTION TSAREA (R, H)
TSAREA = 2 * 3.14 * R * (R + H)
END FUNCTION
WRITE A QBASIC PROGRAM DISPLAY TOTAL VOLUME OF HEMISPHERE.

WRITE A QBASIC PROGRAM DISPLAY TOTAL VOLUME OF HEMISPHERE.

QBASIC PROGRAM FIND TOTAL VOLUME OF HEMISPHERE

Solution:

Display the volume of the hemisphere.


REM PROGRAM TO DISPLAY VOLUME OF HEMISPHERE.
CLS
INPUT “ENTER RADIUS ”; R
V = (2 / 3) * 3.14 * R ^ 3
PRINT “VOLUME OF HEMISPHERE ”; V
END

DISPLAY TOTAL VOLUME OF HEMISPHERE USING SUB PROCEDURE


DECLARE SUB VOLUME(R)
CLS
INPUT “ENTER RADIUS”; R
CALL VOLUME(R)
END

SUB VOLUME (R)
V = (2 / 3) * 3.14 * R ^ 3
PRINT “VOLUME OF HEMISPHERE ”; V
END SUB


DISPLAY TOTAL VOLUME OF HEMISPHERE USING FUNCTION PROCEDURE


DECLARE FUNCTION VOLUME (R)
CLS
INPUT “ENTER RADIUS”; R
PRINT “VOLUME OF HEMISPHERE ”; VOLUME(R)
END

FUNCTION VOLUME (R)
VOLUME = (2 / 3) * 3.14 * R ^ 3
END FUNCTION
WRITE A QBASIC PROGRAM DISPLAY TOTAL SURFACE AREA OF HEMISPHERE.

WRITE A QBASIC PROGRAM DISPLAY TOTAL SURFACE AREA OF HEMISPHERE.

 QBASIC PROGRAM DISPLAY TOTAL SURFACE AREA OF HEMISPHERE.


Solution:

Display the total surface area of the hemisphere.


REM PROGRAM TO DISPLAY TOTAL SURFACE AREA OF HEMISPHERE.
CLS
INPUT “ENTER RADIUS ”; R
A= 3 * 3.14 * R ^ 2
PRINT “TOTAL SURFACE AREA OF HEMISPHERE “; A
END

TOTAL SURFACE AREA OF HEMISPHERE USING SUB PROCEDURE


DECLARE SUB TSAREA (R)
CLS
INPUT “ENTER RADIUS”; R
CALL TSAREA(R)
END

SUB TSAREA (R)
A= 3 * 3.14 * R ^ 2
PRINT “TOTAL SURFACE AREA OF HEMISPHERE “; A
END SUB

TOTAL SURFACE AREA OF HEMISPHERE USING FUNCTION PROCEDURE


DECLARE FUNCTION TSAREA (R)
CLS
INPUT “ENTER RADIUS”; R
PRINT “TOTAL SURFACE AREA OF HEMISPHERE ”; TSAREA(R)
END

FUNCTION TSAREA (R)
TSAREA = 3 * 3.14 * R ^ 2
END FUNCTION