Here - 1000 BiT

Here - 1000 BiT Here - 1000 BiT

11.07.2015 Views

RULE: You cannot do arithmetic with the numbers in strings.Correct:Wrong:Wrong:10 LET A = 3 + 710LETAS = 3 + 710 LET A = "3" + "7"If you run either of these wrong lines, the computer will print:TYPE MISMATCH ERROR IN 10There are two types of variables:number and string.You cannot put a number into a string box or a string into a number box.Enter10LETA=520LETB$="10"30 LET OA+BSLines 10 and 20 are OK, line 30 is wrong. What will the computer do when you run thislittle program?Try to guess what each of these statements will print, then enter the line to see whathappens:PRINT 5PRINT "5"PRINT "5+ 3"PRINT "5"+"3"PRINT5 + 3_62

MIXTURES IN PRINTYou can print numbers and strings in the same PRINT command. (Just remember thatyou cannot do arithmetic with the mixture.)Correct: PRINT A;"SEVEN ";"7"PRINT A;B$Run this line: 10 PRINT 5/2;"IS EQUAL TO 5/2"A FUNNY THING ABOUT THE EQUAL SIGNThe "=" sign in computing does not mean "equals" exactly. Look at this program:10LETN=N+1This does not make sense in arithmetic. Suppose N is 7. This would say that7=7+1which is not correct.But it is OK in computing to say N=N+1 because the "=" sign really means "replace."Here is what happens:Look at this:10 LET N=N+1The computer goes to the box with N written on the front.It takes the number 7 from the box.It adds 1 to the 7 to get 8.Then it puts the 8 into the box.63

MIXTURES IN PRINTYou can print numbers and strings in the same PRINT command. (Just remember thatyou cannot do arithmetic with the mixture.)Correct: PRINT A;"SEVEN ";"7"PRINT A;B$Run this line: 10 PRINT 5/2;"IS EQUAL TO 5/2"A FUNNY THING ABOUT THE EQUAL SIGNThe "=" sign in computing does not mean "equals" exactly. Look at this program:10LETN=N+1This does not make sense in arithmetic. Suppose N is 7. This would say that7=7+1which is not correct.But it is OK in computing to say N=N+1 because the "=" sign really means "replace."<strong>Here</strong> is what happens:Look at this:10 LET N=N+1The computer goes to the box with N written on the front.It takes the number 7 from the box.It adds 1 to the 7 to get 8.Then it puts the 8 into the box.63

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!