0% found this document useful (0 votes)
48 views3 pages

One-Dimensional Array Worksheet 1

The document contains a worksheet with 20 questions focused on one-dimensional arrays in computer science. Each question requires writing pseudocode and program code for various tasks involving arrays, such as inputting data, validating input, searching for values, and performing calculations. The tasks cover a range of scenarios including storing student names, marks, product codes, and more, with an emphasis on algorithm development and array manipulation.

Uploaded by

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

One-Dimensional Array Worksheet 1

The document contains a worksheet with 20 questions focused on one-dimensional arrays in computer science. Each question requires writing pseudocode and program code for various tasks involving arrays, such as inputting data, validating input, searching for values, and performing calculations. The tasks cover a range of scenarios including storing student names, marks, product codes, and more, with an emphasis on algorithm development and array manipulation.

Uploaded by

pharhomes
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Computer Science

Teacher: Maruf Ahmed


One-dimensional array worksheet - 1

Write pseudocode first and then program code for the following questions:
Question 1:
A school wants to store the names of 50 students in a one-dimensional array Names.
Write an algorithm:
• to declare the array and all the other data stores
• to input the names into the array
• to display each name on a new line
Question 2:
A one-dimensional array Marks stores the marks (integer) of 20 students in a test.
Write an algorithm:
• to input the 20 marks. Each mark must be an integer in the range 0 to 100. Apply validation for this
• to find and output the highest mark
Question 3:
A one-dimensional array ProductCode holds 15 integer product codes which are all unique.
Write an algorithm:
• to declare the array and all the other data stores
• to input 15 product codes
• to input a code to search for
• to output “Found” if the code is present, otherwise output “Not Found”
Question 4:
An array Number holds maximum of 30 positive integers. Assume that no more than 30 integers will be given
as input.
Write an algorithm:
• to input the numbers until a value of -1 is given
• to count and output how many numbers are even
• to count and output how many numbers are odd
Question 5:
A one-dimensional array Score stores 10 integer values.
Write an algorithm:
• to input 10 scores which must be in the range from 0 to 100
• to output the scores in reverse order
Question 6:
A one-dimensional array Age holds the ages of 25 students in a class.
Write an algorithm:
• to input the ages (each age must be between 3 and 20)
• to calculate and output the average age
Question 7:
An array Mark holds the marks (0–100) of 15 students.
Write an algorithm:
• to count and output how many students passed (mark >= 50) and how many failed
Question 8:
An array Temp stores 12 temperature readings (Each one must be between -50.0 and 50.0).
Write an algorithm:
• to input the readings
• to find and output the lowest temperature
Question 9:
An array Number holds 20 integers (1 to 1000).
Write an algorithm:
• to display only those numbers that are multiples of 5
Question 10:
An array Code stores 20 integer values.
Write an algorithm:
• to input the 20 codes
• to input another integer called Target
• to count and output how many times Target appears in Code
Question 11:
An array Item holds 10 string items.
Write an algorithm:
• to declare the array all the data stores
• to input the 10 items
• to swap the first and last elements
• to output the updated array
Question 12:
An array Number stores 30 positive integers.
Write an algorithm:
• to calculate and output the sum of all odd numbers
Question 13:
An array Score stores 10 integer scores (0 to 100).
Write an algorithm:
• to input the scores
• to output the second highest score
Question 14:
An array Data stores 10 integer values.
Write an algorithm:
• to declare the array and all the other data stores
• to input 10 values
• to input a new value and position (1 to 11)
• to insert the new value at that position (shift other values right)
• to display the array with 11 values
(Assume the array can hold 11 values)
Question 15:
An array Mark stores 12 integer marks (0 to 100).
Write an algorithm:
• to input the marks
• to calculate and output the range (difference between highest and lowest mark)

Working with multiple arrays together:


Question 16:
Problem: You have two arrays:
• Name[30]: stores student names
• Mark[30]: stores marks of students
Task: Output names of students who scored above 80.
Question 17:
Problem: You have two arrays:
• Product[10]: stores names of products
• Price[10]: stores price of each product
Task: Find and display the product with the highest price.
Question 18:
Problem: You have three arrays:
• ID[20]: student IDs in whole numbers
• Name[20]: student names
• Grade[20]: grades from A to F
Task: Input an ID, and display the name and the grade of that student. Display not found if the ID is not present
Question 19:
Problem: You have two arrays:
• Name[10]: person’s name
• Age[10]: corresponding age
Task: Sort the arrays in ascending order of age and print the names with ages. No unnecessary comparison
should be made.
Question 20:
Problem: You have two arrays:
• Student[15]: list of students
• Subject[15]: corresponding subjects they chose
Task: Input a subject name (in any case small or capital) and list all students who chose it.

You might also like