Doing sums

The command PRINT, followed by a sum, tells the computer to work out the sum and put the answer on the screen. Try the PRINT commands shown below. The commands have no line numbers, so the computer carries out each one straight away.

PRINT 2+2
PRINT 2*3
PRINT 6/2
PRINT 2-4

Hours program

This program makes the computer work out the number of hours in a year. Line 30 does the calculation. It multiplies the number of days in a year, by the number of hours in a day.

Let’s type it in and RUN it now.

NEW
10 CLS
20 PRINT "THERE ARE "
30 PRINT 365*24
40 PRINT "HOURS IN"
50 PRINT " A YEAR"
RUN

Notice that there are spaces in the strings we're printing above, which look like they're intended for the message to be printed out on one line, but because PRINT outputs on a new line, the spaces aren't really necessary.

You can modify a PRINT so it doesn't end with a new line by putting a semicolon after it. Try editing your program using EDIT followed by a line number, to add semicolons to the end of lines 20, 30 and 40, then run it again.

Your code should end up looking like this:

10 CLS
20 PRINT "THERE ARE ";
30 PRINT 365*24;
40 PRINT "HOURS IN";
50 PRINT " A YEAR"