Docsity

Arrays: Storing and Manipulating Student Data, Schemes and Mind Maps of Economics

Partial preview of the text

Download Arrays: Storing and Manipulating Student Data and more Schemes and Mind Maps Economics in PDF only on Docsity!

Arrays

How to Store values into an Array

Q. Store 5 students Marks in an array.

For C  1 to 5

Input Mark

arrMark[C]  Mark

Next C

Q. Store 5 students Names in an array.

For C  1 to 5

Input Name

arrName[C]  Name

Next C

How to output values stored in an Array

Q. Output 5 students Marks in an array.

For C  1 to 5

Output arrMark[C]

Next C

Scenario Input and store the names and marks for 30 students who have sat three computer science tests. Test 1 is out of 20 marks, Test 2 is out of 25 marks, Test 3 is out of 35 marks. You must store the names in a one-dimensional array and the marks and total score for each student in one-dimensional arrays. All the marks must be validated on entry and any invalid marks rejected. You may assume that the students’ names are unique. Calculate and store the total score for each student and calculate the average score for the whole class. Output each student’s name followed by their total score, and then output the average score for the class.

  1. How to declare arrays for above scenario? StudentNames[ 1 : 30 ] StudentMarksTest1[1: 30 ] StudentMarksTest2[1: 30 ] StudentMarksTest3[1: 30 ] StudentTotalScore[1: 30 ]
  2. Write an algorithm using pseudo code for above scenario. No need to include any validation. Sum  0 FOR Count  1 TO 30 INPUT Name StudentName[Count] Name INPUT Mark 1 , Mark 2 , Mark StudentMarksTest1[Count]Mark StudentMarksTest2[Count] Mark StudentMarksTest3[Count]  Mark Total  Mark1 + Mark2 + Mark StudentTotalScore[Count]  Total Sum  Sum + Total Keep the index of the array. Store values to a slot in a array Output values stored in a array PRINT StudentName[Count], StudentTotalScore[Count] NEXT Count ClassAverage = Sum/ 30 PRINT ClassAverage