Exercises For Chapter 11. More Things You Can Do With Basic - IBM 5110 Basic Introduction

Table of Contents

Advertisement

c:
C "
v
Exercises for Chapter 11. More Things You Can Do with BASIC
Problem 1
Make a chart of the values of sine and cosine of X, as X goes from 0°
through 360
0
in 45
0
steps.
The Program
o
0 lOP PIN
'r
'Ii [: Ci
i = < [
E ::::; ..'
'~:::
1\1'!
o
0 ? 0 F D
F~
>< ::::
0 TO :-3 (.
I)
E T E F
i.j. ' . ::' ;
o
0 :3 0 Y' :::: R
(I
II (
~<
; :
0040 PRINT XISIN(Y)!COS(Y)
o
0
~.:.;
0 NEXT
><
0060
~:)TOP
Problem 2
You are going to bake a cake. The recipe calls for an 8-inch square
pan. You only have an 8-inch round pan, and a 9-inch round pan.
Which pan will have a surface area closest to the required one?
The Program
00:1. 0
f:;B~::B~~B
0020 R8=&PI*(4t2)
0030 R9=&PI*(4,5t2)
o
0 1+ 0 II :I. ::::
~:)
n . . . .
F~
B
o
0
~:5
0 P
I~
I
NT' T H F B ....
INC
H P
i~
N
I
~:~
, . '
n
1.
J
'~:;)
o
0 b 0 1:1 2 ::::
~:)
B ....
I~
'ji
007'0
IF D2<O
GOTO
100
() 0 BOP PIN T 'T HE? .... INC H P (:, N I
~:)
, . '
I
b
Q
U
(~! i~
E INC H E
~3
~:;
f"l
tl
L
I...
F P ,
0090 GOTO :1.10
o
:I. ()
0 P
F~
I NT' THE
i.
y .... INC H P f., N I f;
I
! .... D 2! .
~::; C~
l...l
,~!
HE
:I:
N C H E
~:)
BID G E
F~
,
o
:l.
1. 0 :0 2 :::: A B
~:)
( II:? )
0120 IF D1<D2 GOlD 150
o
1 3 0 P
Ix
I NT' THE ? .... INC H P
(.~,
N I
~:;
C
I... (]
~:)
I:::
I~~
l (] THE R E Q
1...1
I P E D
~:)
I Z E '
o
:I.
1+
0 GOT 0
16 0
O:l.~.:.:.iO
PF~INl
'THE B .... li"·lCH Pf.,N In
CI...O~3Elx
TO THE
PEQUIF~ED
~:;IZE'
0:1.60
~:)TDP
Exercises
143
c:
C "
v
Exercises for Chapter 11. More Things You Can Do with BASIC
Problem 1
Make a chart of the values of sine and cosine of X, as X goes from 0°
through 360
0
in 45
0
steps.
The Program
o
0 lOP PIN
'r
'Ii [: Ci
i = < [
E ::::; ..'
'~:::
1\1'!
o
0 ? 0 F D
F~
>< ::::
0 TO :-3 (.
I)
E T E F
i.j. ' . ::' ;
o
0 :3 0 Y' :::: R
(I
II (
~<
; :
0040 PRINT XISIN(Y)!COS(Y)
o
0
~.:.;
0 NEXT
><
0060
~:)TOP
Problem 2
You are going to bake a cake. The recipe calls for an 8-inch square
pan. You only have an 8-inch round pan, and a 9-inch round pan.
Which pan will have a surface area closest to the required one?
The Program
00:1. 0
f:;B~::B~~B
0020 R8=&PI*(4t2)
0030 R9=&PI*(4,5t2)
o
0 1+ 0 II :I. ::::
~:)
n . . . .
F~
B
o
0
~:5
0 P
I~
I
NT' T H F B ....
INC
H P
i~
N
I
~:~
, . '
n
1.
J
'~:;)
o
0 b 0 1:1 2 ::::
~:)
B ....
I~
'ji
007'0
IF D2<O
GOTO
100
() 0 BOP PIN T 'T HE? .... INC H P (:, N I
~:)
, . '
I
b
Q
U
(~! i~
E INC H E
~3
~:;
f"l
tl
L
I...
F P ,
0090 GOTO :1.10
o
:I. ()
0 P
F~
I NT' THE
i.
y .... INC H P f., N I f;
I
! .... D 2! .
~::; C~
l...l
,~!
HE
:I:
N C H E
~:)
BID G E
F~
,
o
:l.
1. 0 :0 2 :::: A B
~:)
( II:? )
0120 IF D1<D2 GOlD 150
o
1 3 0 P
Ix
I NT' THE ? .... INC H P
(.~,
N I
~:;
C
I... (]
~:)
I:::
I~~
l (] THE R E Q
1...1
I P E D
~:)
I Z E '
o
:I.
1+
0 GOT 0
16 0
O:l.~.:.:.iO
PF~INl
'THE B .... li"·lCH Pf.,N In
CI...O~3Elx
TO THE
PEQUIF~ED
~:;IZE'
0:1.60
~:)TDP
Exercises
143

Advertisement

Table of Contents
loading

Table of Contents