Ask Question, Ask an Expert

+61-413 786 465

info@mywordsolution.com

Ask Programming Language Expert

Pass Task 5.1: Hand Execution of Arrays

Overview

Arrays are key to understanding how the computer can work with large amounts of data. When you understand how arrays work you will be ready to start making more complex programs.

Purpose: Learn about how arrays work in the computer.

Task: Hand execute the provided code snippets to demonstrate key aspects of working with arrays.

Instructions

Arrays are incredibly useful, and really important to understand. Hand execution can really help you understand these more fully.

To represent an array draw a box divided into sections for each value. This represent the array's location in memory, providing you with access to the array as a whole and to the individual elements.

The following is an example of how to represent an array in your Hand Execution.

1401_figure.jpg

Demonstrate how the following code is executed in the computer.

function ???(const data: array of Integer): Integer;
var
i: Integer;
begin
result := 0;

for i := Low(data) to High(data) do begin
result := result + data[ i ];
end; end;

Hand Execute the program with the following parameter values to see if you can work out what it does.

data

Result

[6, -2, 3, 8, 1]

 

[2, 6, -1, 3]

 

Provide a name for this on your hand execution images.

The following code performs a useful tasks with an array of Integer values. What does it do?

function ???(const data: array of Integer;
val: Integer): Boolean;
var
i: Integer;
begin
result := False;

for i := Low(data) to High(data) do begin
if data[i] = val then begin
result := True;
exit; // end the function
end;
end; end;

Hand execute the function with the following parameter values.

data

val

Result

[2, 6, -3, 3, 7]

3

 

[-1, 8, 2, -4, 9]

6

 

Provide a suitable name for this function on your hand execution image you submit.

Questions

List the actions the computer executes when it runs the following code.

for i := 0 to 3 do begin
WriteLn('i is ', i);
end;

List the actions the computer executes when it runs the following code.

for i := 3 downto 0 do begin
WriteLn('i is ', i);
end;

Assume that names is an array of three names. Names array:

List the actions the computer executes when it runs the following code.
WriteLn('Array of ', Length(names), ' values'); for i := 0 to High(names) do
begin
WriteLn(names[i]);
end;

Assume that a Score record contains a name and a score, and that the scores variable is an array of three Score record values.
Scores array:

Index

Value

0

Name: Fred

Score: 10

1

Name: Wilma

Score: 20

2

Name: Betty

Score: 15

Assume you also have the following procedure:

procedure WriteScore(const toWrite: Score); begin
WriteLn(toWrite.name, ' scored ', toWrite.score);
end;

What will be output when the computer runs the following code:

WriteLn( 'Message 0' ); WriteLn( scores[1].Name ); WriteLn();

WriteLn( 'Message 1' );
for i := 0 to High(scores) do begin
WriteLn( scores[i].Name );
end;

WriteLn();
WriteLn( 'Message 2' );
for i := 0 to High(scores) do begin
WriteScore(scores[i]);
end;a

Programming Language, Programming

  • Category:- Programming Language
  • Reference No.:- M91780506

Have any Question?


Related Questions in Programming Language

Task - hand execution of arraysoverviewin this task you

Task - Hand Execution of Arrays Overview In this task you will demonstrate how arrays work by hand executing a number of small code snippets. Instructions Watch the Hand Execution with Arrays video, this shows how to ste ...

Task working with arraysoverviewin this task you will

Task: Working with Arrays Overview In this task you will create a simple program which will create and work with an array of strings. This array will then be populated with values, printed out to the console, and then, w ...

Extend the adworks applicationi add dialogs to allow the

Extend the AdWorks application I. Add Dialogs to allow the user to Add, Edit, Read and Delete a Customer and refresh the view accordingly. 1. The user should be able to select a specific customer from the DataGrid and cl ...

Question 1 what is hadoop explaining hadoop 2 what is

Question: 1. What is Hadoop (Explaining Hadoop) ? 2. What is HDFS? 3. What is YARN (Yet Another Resource Negotiator)? The response must be typed, single spaced, must be in times new roman font (size 12) and must follow t ...

Task silly name testeroverviewcontrol flow allows us to

Task: Silly Name Tester Overview Control flow allows us to alter the order in which our programs execute. Building on our knowledge of variables, we can now use control flow to create programs that perform more than just ...

Background informationthis assignment tests your

Background Information This assignment tests your understanding of and ability to apply the programming concepts we have covered throughout the unit. The concepts covered in the second half of the unit build upon the fun ...

Assignment - horse race meetingthe assignment will assess

Assignment - Horse Race Meeting The Assignment will assess competencies for ICTPRG524 Develop high level object-oriented class specifications. Summary The assignment is to design the classes that are necessary for the ad ...

1 write a function named check that has three parameters

1. Write a function named check () that has three parameters. The first parameter should accept an integer number, andthe second and third parameters should accept a double-precision number. The function body should just ...

Assignment - haskell program for regular expression

Assignment - Haskell Program for Regular Expression Matching Your assignment is to modify the slowgrep.hs Haskell program presented in class and the online notes, according to the instructions below. You may carry out th ...

Task arrays and structsoverviewin this task you will

Task: Arrays and Structs Overview In this task you will continue to work on the knight database to help Camelot keep track of all of their knights. We can now add a kingdom struct to help work with and manage all of the ...

  • 4,153,160 Questions Asked
  • 13,132 Experts
  • 2,558,936 Questions Answered

Ask Experts for help!!

Looking for Assignment Help?

Start excelling in your Courses, Get help with Assignment

Write us your full requirement for evaluation and you will receive response within 20 minutes turnaround time.

Ask Now Help with Problems, Get a Best Answer

Why might a bank avoid the use of interest rate swaps even

Why might a bank avoid the use of interest rate swaps, even when the institution is exposed to significant interest rate

Describe the difference between zero coupon bonds and

Describe the difference between zero coupon bonds and coupon bonds. Under what conditions will a coupon bond sell at a p

Compute the present value of an annuity of 880 per year

Compute the present value of an annuity of $ 880 per year for 16 years, given a discount rate of 6 percent per annum. As

Compute the present value of an 1150 payment made in ten

Compute the present value of an $1,150 payment made in ten years when the discount rate is 12 percent. (Do not round int

Compute the present value of an annuity of 699 per year

Compute the present value of an annuity of $ 699 per year for 19 years, given a discount rate of 6 percent per annum. As