85.7k views
0 votes
write a QBASIC program to calculate the perimeter of calculate the perimeter of circle [hint p=2pi r]​

User Paleonix
by
7.7k points

2 Answers

3 votes

Answer:

A QBASIC program to calculate the perimeter of a circle

DECLARE SUB CIRCUM (R)

CLS

INPUT “ENTER RADIUS"; R

CALL CIRCUM (R)

END

SUB CIRCUM (R)

C=2*3.14 * R

PRINT "CIRCUMFERENCE OF CIRCLE "; C

END SUB

User Ilario
by
8.0k points
1 vote

Here's an example program in QBASIC that calculates the perimeter of a circle using the formula P = 2πr:

REM QBASIC program to calculate the perimeter of a circle

INPUT "Enter the radius of the circle: ", r

p = 2 * 3.14159 * r

PRINT "The perimeter of the circle is "; p

END

This program prompts the user to enter the radius of the circle, then calculates the perimeter using the formula P = 2πr. The result is displayed using the PRINT statement.

Note that the value of π is approximated as 3.14159 in this example. You could increase the precision by using a more accurate value of π or by using QBASIC's built-in constant for π, which is named PI.

User Lyk
by
8.3k points