Here - 1000 BiT

Here - 1000 BiT Here - 1000 BiT

11.07.2015 Views

Assignment 17B:1. Write a program which prints your name 15 times.2. Now make it indent each time by two spaces more. It will go diagonally down thescreen. Use TAB in a loop.3. Now make it write your name 23 times, starting at the bottom of the screen and goingup. Use the "up" keys in a PRINT and put it all into a loop.4. Now make it write your name on one line, your friend's name on the next and keepswitching until each name is written five times. Make each name a different color.5. Write a program with loops nested three deep. Do the outer loop three times and haveit print SING. Make it change the screen color each time through. The next loop printsTRA. Have it loop three times. The innermost loop prints LA three times.102

^ INSTRUCTOR NOTES 18 DATA, READ, RESTOREThis lesson concerns the DATA statement. READ gets data from the DATA statementsr*) and RESTORE puts the pointer back to the beginning of the first DATA statement.O The storing of data in DATA statements has a few confusing elements when firstconfronted. You can never change any of the data in the statement unless you rewrite the^ program. Of course, you can READ the data into a variable box, then change what's in^the box.^ You must READ the data to be able to use it. It must be read in order, starting from thebeginning. If you want to skip some data, you have to read and throw away the stuffr*\ before it. (This procedure is not discussed in the lesson, and may be mentioned to thestudent when other ideas about DATA are well entrenched.)^ The idea of a "pointer" is used in this lesson. A pencil in the hand of the instructor,nnpointing to items in a DATA statement, helps clarify this concept.Using DATA saves some error prone typing if you have a lot of data.However, it is also useful in cases where there is not really very much data because it^ clearly separates the actual data from the processing of the data. This helps when^debugging programs.r*) One of the most common uses of DATA is to fill arrays with initial values. We also use itin the MUSIC lesson to store note pitches and durations.^n^QUESTIONS:1. What happens if you try to READ more data items than are in the DATA statements?2. What rule tells you where to put the DATA statements in the program? How aboutwhere to put the READ statements?3. The idea of a "pointer" helps in thinking about the DATA statements. Explain how.n4. Can you put numeric data and string data into the same DATA statement?■■5. What happens if you try to READ a string into a numeric variable?r^ 6. Can you change the items in a DATA statement while the program runs?nnnn ...n 103

^ INSTRUCTOR NOTES 18 DATA, READ, RESTOREThis lesson concerns the DATA statement. READ gets data from the DATA statementsr*) and RESTORE puts the pointer back to the beginning of the first DATA statement.O The storing of data in DATA statements has a few confusing elements when firstconfronted. You can never change any of the data in the statement unless you rewrite the^ program. Of course, you can READ the data into a variable box, then change what's in^the box.^ You must READ the data to be able to use it. It must be read in order, starting from thebeginning. If you want to skip some data, you have to read and throw away the stuffr*\ before it. (This procedure is not discussed in the lesson, and may be mentioned to thestudent when other ideas about DATA are well entrenched.)^ The idea of a "pointer" is used in this lesson. A pencil in the hand of the instructor,nnpointing to items in a DATA statement, helps clarify this concept.Using DATA saves some error prone typing if you have a lot of data.However, it is also useful in cases where there is not really very much data because it^ clearly separates the actual data from the processing of the data. This helps when^debugging programs.r*) One of the most common uses of DATA is to fill arrays with initial values. We also use itin the MUSIC lesson to store note pitches and durations.^n^QUESTIONS:1. What happens if you try to READ more data items than are in the DATA statements?2. What rule tells you where to put the DATA statements in the program? How aboutwhere to put the READ statements?3. The idea of a "pointer" helps in thinking about the DATA statements. Explain how.n4. Can you put numeric data and string data into the same DATA statement?■■5. What happens if you try to READ a string into a numeric variable?r^ 6. Can you change the items in a DATA statement while the program runs?nnnn ...n 103

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

Saved successfully!

Ooh no, something went wrong!