0% found this document useful (0 votes)
60 views

Worksheet 13.1/14.1: For Testing Basic Understanding: © Cambridge University Press 2019

This document contains instructions for a series of programming exercises to test basic understanding of arrays and file input/output in programming. The exercises involve initializing arrays with increasing numbers, incrementing array elements based on user input, initializing and modifying a 2D array based on user coordinates, reading and writing text from files.

Uploaded by

Indu Lakshmi
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
60 views

Worksheet 13.1/14.1: For Testing Basic Understanding: © Cambridge University Press 2019

This document contains instructions for a series of programming exercises to test basic understanding of arrays and file input/output in programming. The exercises involve initializing arrays with increasing numbers, incrementing array elements based on user input, initializing and modifying a 2D array based on user coordinates, reading and writing text from files.

Uploaded by

Indu Lakshmi
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 1

Worksheet 13.1/14.

1: for testing
basic understanding
1 Write a program to initialise an array with ten elements. Each element is to contain the number 0.
The program should output the contents of the array.
2 Amend your program from Question 1 so the first element contains 1, the second element contains 2,
and so on.
3 Amend your program from Question 1. After initialisation the program should ask repeatedly for an integer
between 1 and 10 until the input is terminated by 0. For each input, the relevant array element content
should be increased by 1. For example, if the input is 5, the fifth element should be incremented by 1.
4 Write a program to initialise a 5 × 5 array. Each element should contain the number 0. The program should
output the contents of the array.
5 Amend your program from Question 4. After initialisation the program should ask repeatedly for two integers
between 1 and 5 until the input is terminated by 0. The two input numbers should be used as coordinates
(row number followed by column number) and the contents of the relevant array element should be
increased by 1.
For example, if the first two input numbers are 2 and 3, the array contents should be:
00000
00100
00000
00000
00000
6 Create a text file with several lines of text in a text editor (for example NotePad).
Write a program to read this text file and output the contents.
7 Amend your program from Question 6 to output the text from the first text file to another text file. Open the
newly created text file in a text editor to check the program worked successfully.

© Cambridge University Press 2019

You might also like