Vtech PreComputer Power Pad Plus User Manual - Page 50

Print The Celsius Temp Is;c

Page 50 highlights

MORE ABOUT GROUPS - GOSUB ... RETURN How much is 10 degrees Celsius in Fahrenheit? What is 100 degrees Fahrenheit in Celsius? Here's a program that gives you the answers. It uses the GOSUB and RETURN statements to create a group of instructions that can be executed from various parts of the program. Remember when you use a GOSUB, the program branches to the line number that you specify in the statements that will be executed sequentially until a RETURN statement is encountered. At that point the program will resume at the next statement following the GOSUB. Confusing? Not really, but first some more background about our problem. The formula for converting Celsius to Fahrenheit is: F=(9/5*C)+32 The formula for converting Fahrenheit to Celsius is: C=(F-32)*5/9 Now for the program! Type: New 10 INPUT "ENTER THE CELSIUS TEMP";C 20 GOSUB 500 30 INPUT "ENTER THE FAHRENHEIT TEMP";F 40 GOSUB 600 50 END 500 F=(C*9/5)+32 510 PRINT "THE FAHRENHEIT TEMP IS";F 520 RETURN 600 C=(F-32)*5/9 610 PRINT "THE CELSIUS TEMP IS";C 630 RETURN RUN 46

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51
  • 52
  • 53
  • 54
  • 55
  • 56
  • 57
  • 58
  • 59
  • 60
  • 61
  • 62
  • 63
  • 64
  • 65
  • 66
  • 67
  • 68
  • 69
  • 70
  • 71
  • 72
  • 73
  • 74
  • 75
  • 76
  • 77
  • 78
  • 79
  • 80
  • 81
  • 82
  • 83
  • 84
  • 85
  • 86
  • 87
  • 88

46
MORE ABOUT GROUPS - GOSUB ...
RETURN
How much is 10 degrees Celsius in Fahrenheit?
What is 100 degrees Fahrenheit in Celsius?
Here’s a program that gives you the answers.
It uses the
GOSUB
and
RETURN
statements
to create a group of instructions that can be executed from various parts of the program.
Remember when you use a
GOSUB
, the program branches to the line number that you
specify in the statements that will be executed sequentially until a
RETURN
statement is
encountered.
At that point the program will resume at the next statement following the
GOSUB
. Confusing? Not really, but first some more background about our problem.
The formula for converting Celsius to Fahrenheit is
:
F=(9/5*C)+32
The formula for converting Fahrenheit to Celsius is
:
C=(F-32)*5/9
Now for the program!
Type
:
New
10
INPUT “ENTER THE CELSIUS TEMP”;C
20
GOSUB 500
30
INPUT “ENTER THE FAHRENHEIT TEMP”;F
40
GOSUB 600
50
END
500
F=(C*9/5)+32
510
PRINT “THE FAHRENHEIT TEMP IS”;F
520
RETURN
600
C=(F-32)*5/9
610
PRINT “THE CELSIUS TEMP IS”;C
630
RETURN
RUN