I'm terrible at programming and missed the last class. I haven't

been able to find anyone that could help me understand the last work

we were given . I was hoping someone might be able

to explain this to me. I won't receive a grade in this until I complete

all my work and I don't seem to be able to get past this.

self-check pg. 439 #1: (on arrays) Turbo Pascal

The following sequence of statements changes the contents of array X.

Describe what each statement does to the array, and show the final

contents of array X after all statements execute.

X = array

I = index range

I :=3;

X[I] := X[I] + 10.0;

X[I - 1] := X[2 * 1 - 1];

X[I + 1] := X[2 * 1] + X[2 * I + 1);

for I :=3 downto 1 do

X[I + 1] := X[I]

I would appreciate any help I can get with this.

Serina

It looks like you're new here. If you want to get involved, click one of these buttons!

- 140.8K All Categories
- 103.6K Programming Languages
- 6.4K Assembler Developer
- 401 Assembly Code Share
- 239 Getting started in assembly
- 4.6K x86 Assembly
- 1.9K Basic
- 97 Qbasic
- 39.9K C and C++
- 5.6K Beginner C/C++
- 330 C/C++ on Linux/Unix
- 450 C/C++ Windows API
- 522 C++ Builder
- 253 C++ Game Development
- 3.3K C++ MFC
- 103 C++.NET
- 404 Visual C++
- 2.9K C#
- 7.9K Delphi and Kylix
- 334 Advanced Delphi
- 360 Delphi beginners
- 4 Haskell
- 9.7K Java
- 56 Enterprise JavaBeans
- 1.3K Java Beginners
- 304 Java Server Pages
- 4.1K Pascal
- 1.3K Perl
- 11 Perl 6
- 2K PHP
- 546 Python
- 37 Ruby
- 4.4K VB.NET
- 258 Advanced VB.Net
- 1.6K VBA
- 20.8K Visual Basic
- 767 Access databases and VB
- 831 Advance Visual Basic
- 1.2K Beginner VB
- 2.6K Game programming
- 315 Console programming
- 90 DirectX Game dev
- 1 Minecraft
- 112 Newbie Game Programmers
- 2 Oculus Rift
- 9K Applications
- 1.8K Computer Graphics
- 279 3D Graphics
- 129 DirectX
- 125 OpenGL
- 740 Computer Hardware
- 9 Cooling & Overclocking
- 3.4K Database & SQL
- 1.1K Access
- 91 ADO Programming
- 288 MySQL
- 358 Oracle
- 440 SQL-Server
- 535 Electronics development
- 1.6K Matlab
- 628 Sound & Music
- 25 DirectSound
- 257 XML Development
- 3.3K Classifieds
- 199 Co-operative Projects
- 198 For sale
- 190 FreeLance Software City
- 1.9K Jobs Available
- 603 Jobs Wanted
- 209 Wanted
- 2.9K Microsoft .NET
- 1.8K ASP.NET
- 1.1K .NET General
- 22 .NET WEB-Services
- 129 .NET WinForms
- 14 .NET XML
- 50 ADO.NET
- 142 C# & VB.NET School Support
- 3.4K Miscellaneous
- 8 Join the Team
- 354 Comments on this site
- 69 Computer Emulators
- 2.1K General programming
- 187 New programming languages
- 621 Off topic board
- 200 Mobile & Wireless
- 72 Android
- 126 Palm Pilot
- 338 Multimedia
- 154 Demo programming
- 184 MP3 programming
- 0 Bash scripts
- 27 Cloud Computing
- 1 Witsbits Go Cloud
- 53 FreeBSD
- 1.7K LINUX programming
- 1 Awk scripting
- 332 Linux Support
- 0 Sed scripting
- 370 MS-DOS
- 0 Shell scripting
- 321 Windows CE & Pocket PC
- 4.1K Windows programming
- 177 COM/DCOM
- 61 Networking And Security
- 17 Windows 2003 Server
- 6 Windows Vista
- 176 Windows XP
- 939 Software Development
- 416 Algorithms
- 68 Object Orientation
- 24 RUP & UML
- 91 Project Management
- 95 Quality & Testing
- 268 Security
- 63 Evil Scripting
- 81 Hacking
- 7.7K WEB-Development
- 1.8K Active Server Pages
- 61 AJAX
- 4 Bootstrap Themes
- 55 CGI Development
- 28 ColdFusion
- 224 Flash development
- 1.4K HTML & WEB-Design
- 1.4K Internet Development
- 131 Mobile Internet & Messaging
- 211 Wireless development
- 2.2K JavaScript
- 37 JQuery
- 304 WEB Servers
- 153 Apache
- 79 IIS
- 150 WEB-Services / SOAP

## Comments

: I'm terrible at programming and missed the last class. I haven't

: been able to find anyone that could help me understand the last work

: we were given . I was hoping someone might be able

: to explain this to me. I won't receive a grade in this until I complete

: all my work and I don't seem to be able to get past this.

:

: self-check pg. 439 #1: (on arrays) Turbo Pascal

: The following sequence of statements changes the contents of array X.

: Describe what each statement does to the array, and show the final

: contents of array X after all statements execute.

:

: X = array

: I = index range

:

: I :=3;

: X[I] := X[I] + 10.0;

: X[I - 1] := X[2 * 1 - 1];

: X[I + 1] := X[2 * 1] + X[2 * I + 1);

: for I :=3 downto 1 do

: X[I + 1] := X[I]

:

: I would appreciate any help I can get with this.

: Serina

Hey Serina,

First off, you need to understand what an array is. Think of it like a row of boxes on graph paper. In this case, we'll use 10 boxes in a row and number them from 1..10 You can change put tick marks in any one box, but it will only effect the one.

For the example above:

I :=3;

so just change all the 'I' to '3'. The second line then becomes:

X[3] := X[3] + 10.0;

So box #3 gets 10.0 ticks added to it.

X[3 - 1] := X[2 * 1 - 1];

So box #2 (3-1) will get the same number of ticks that are in box #1 (2*1-1). So if Box[1] (Box #1) has 6 tick marks, then you would make it so box[2] has 6 tick marks as well.

Hope this helps a bit. Monday mornings are not a good time to catch me...

Phat Nat

: : I'm terrible at programming and missed the last class. I haven't

: : been able to find anyone that could help me understand the last work

: : we were given . I was hoping someone might be able

: : to explain this to me. I won't receive a grade in this until I complete

: : all my work and I don't seem to be able to get past this.

: :

: : self-check pg. 439 #1: (on arrays) Turbo Pascal

: : The following sequence of statements changes the contents of array X.

: : Describe what each statement does to the array, and show the final

: : contents of array X after all statements execute.

: :

: : X = array

: : I = index range

: :

: : I :=3;

: : X[I] := X[I] + 10.0;

: : X[I - 1] := X[2 * 1 - 1];

: : X[I + 1] := X[2 * 1] + X[2 * I + 1);

: : for I :=3 downto 1 do

: : X[I + 1] := X[I]

: :

: : I would appreciate any help I can get with this.

: : Serina

:

:

: Thanx Nat,

I appreciate your time. I think I understand it better.

Is this right?

1. I :=3; {index = 3}

2. X[3] := X[3] +10; {stores value of 10 in index 3}

3. X[3 - 1] := X[2 * 3 - 1]; {stores same value in index [2] as in index[5]}

4. X[3 + 1] := X[2 * 3] + X[2 * 3 + 1]; {index 4 = sum of index 6 and index 7}

5. for I := 5 to 7 do {initilizes I to 5}

6. X[I] := X[I + 1]; {adds 1 to I}

{index 5 := 5 + 1}

{index 6 := 6 + 1}

{index 7 := 7 +1}

7. for I := 3 down to 1 do {initializes I to 3}

8. X[3 + 1] := X[3] {adds 1 to I}

{X[2 + 1] := X[2]}

{X[1 + 1] := X[1]}

Does this look ok or am I still way off?

Thanx,

Serina

: : : I'm terrible at programming and missed the last class. I haven't

: : : been able to find anyone that could help me understand the last work

: : : we were given . I was hoping someone might be able

: : : to explain this to me. I won't receive a grade in this until I complete

: : : all my work and I don't seem to be able to get past this.

: : :

: : : self-check pg. 439 #1: (on arrays) Turbo Pascal

: : : The following sequence of statements changes the contents of array X.

: : : Describe what each statement does to the array, and show the final

: : : contents of array X after all statements execute.

: : :

: : : X = array

: : : I = index range

: : :

: : : I :=3;

: : : X[I] := X[I] + 10.0;

: : : X[I - 1] := X[2 * 1 - 1];

: : : X[I + 1] := X[2 * 1] + X[2 * I + 1);

: : : for I :=3 downto 1 do

: : : X[I + 1] := X[I]

: : :

: : : I would appreciate any help I can get with this.

: : : Serina

: :

: :

: : Thanx Nat,

: I appreciate your time. I think I understand it better.

: Is this right?

: 1. I :=3; {index = 3}

:

: 2. X[3] := X[3] +10; {stores value of 10 in index 3}

:

: 3. X[3 - 1] := X[2 * 3 - 1]; {stores same value in index [2] as in index[5]}

:

: 4. X[3 + 1] := X[2 * 3] + X[2 * 3 + 1]; {index 4 = sum of index 6 and index 7}

:

: 5. for I := 5 to 7 do {initilizes I to 5}

:

: 6. X[I] := X[I + 1]; {adds 1 to I}

: {index 5 := 5 + 1}

: {index 6 := 6 + 1}

: {index 7 := 7 +1}

:

: 7. for I := 3 down to 1 do {initializes I to 3}

:

: 8. X[3 + 1] := X[3] {adds 1 to I}

: {X[2 + 1] := X[2]}

: {X[1 + 1] := X[1]}

:

: Does this look ok or am I still way off?

: Thanx,

: Serina

:

A number of your explanations is still a little off. These are 2 and 5 thru 8. 5 & 6 are actually 2 parts of the same statement:

[code]

for I := 5 to 7 do

X[I] := X[I + 1]; { <== statement ends here }

[/code]

Just remember that Pascal uses a semicolon as statement separator. The for-do loop does a little more than initializing I to 5. It also checks if I <= 7 and increments I with each step. The same goes for 7 & 8.

: I appreciate your time. I think I understand it better.

: Is this right?

: 1. I :=3; {index = 3}

:

: 2. X[3] := X[3] +10; {stores value of 10 in index 3}

:

: 3. X[3 - 1] := X[2 * 3 - 1]; {stores same value in index [2] as in index[5]}

:

: 4. X[3 + 1] := X[2 * 3] + X[2 * 3 + 1]; {index 4 = sum of index 6 and index 7}

:

: 5. for I := 5 to 7 do {initilizes I to 5}

:

: 6. X[I] := X[I + 1]; {adds 1 to I}

: {index 5 := 5 + 1}

: {index 6 := 6 + 1}

: {index 7 := 7 +1}

:

: 7. for I := 3 down to 1 do {initializes I to 3}

:

: 8. X[3 + 1] := X[3] {adds 1 to I}

: {X[2 + 1] := X[2]}

: {X[1 + 1] := X[1]}

:

: Does this look ok or am I still way off?

: Thanx,

: Serina

Pretty close. There are just a few that are a little off:

X = array

I = index range

1. I :=3;

1. I :=3; {index = 3}

2. X[I] := X[I] + 10.0;

[b]2. X[3] := X[3] +10; {stores value of 10 in index 3}[/b]

[italic]This actually adds 10 to the existing value. If X[3] was set to 5, then this would make it 15[/italic]

3. X[I-1] := X[2*I-1];

3. X[3-1] := X[2*3-1]; {stores same value in index [2] as in index[5]}

4. X[3+1] := X[2*3] + X[2*3+1]; {index 4 = sum of index 6 and index 7}

5. for I := 5 to 7 do {initilizes I to 5}

[b]this is a loop; usually used with BEGIN and END. This will set I=5, then add one until I=7. Example:[/b]

[code]

For I := 5 to 7 Do

Begin

WriteLn(I);

End;

[/code]

[b]If you ran this, You would see:[/b]

[code]5

6

7[/code]

6. X[I] := X[I + 1]; {adds 1 to I}

{index 5 := 5 + 1}

{index 6 := 6 + 1}

{index 7 := 7 + 1}

[b]

{index 5 := index 6 (5 + 1)}

{index 6 := index 7 (6 + 1)}

{index 7 := index 8 (7 + 1)}

[/b]

7. for I :=3 downto 1 do

X[I + 1] := X[I]

7. For I := 3 down to 1 do {initializes I to 3}

X[3 + 1] := X[3] {adds 1 to I}

{X[2 + 1] := X[2]}

{X[1 + 1] := X[1]}

[b]For I := 3 down to 1 do {initializes I to 3}

X[3 + 1] := X[3] {index 4 (3+1) = index[3]}

{X[2 + 1] := X[2]}

{X[1 + 1] := X[1]}

[/b][italic]When DOWNTO is used in place of TO, I counts down, instead of up[/italic]

Hope this clears up any problems. If you need more help, just leave a message.

Phat Nat

: [code]

: for I := 5 to 7 do

: X[I] := X[I + 1]; { <== statement ends here }

: [/code]

: Just remember that Pascal uses a semicolon as statement separator. The for-do loop does a little more than initializing I to 5. It also checks if I <= 7 and increments I with each step. The same goes for 7 & 8.

:Thanks zibadian,

That helped, I'm working on it.

Serina

:

: Thanx Phat Nat,

This is making more sense to me. This is what I have now:

: X = array

I = index range

1. I :=3; {index = 3}

:

: 2. X[3] := X[3] +10; {adds value of 10 in index 3}

:

: 3. X[3 - 1] := X[2 * 3 - 1]; { same value in index [2] as in

index[5]}

:

: 4. X[3 + 1] := X[2 * 3] + X[2 * 3 + 1];

{index 4 = sum of index 6 and index 7}

:

: 5. for I := 5 to 7 do {initilizes I to 5}

: X[I] := X[I + 1]; {checks if I is <=7 and adds 1 to I}

: {loop}

{index 5 := index 6 (5 + 1)}

: {index 6 := index 7 (6 + 1)}

: {index 7 := index 8 (7 + 1)}

:

: 6. for I := 3 down to 1 do {initializes I to 3}

: X[3 + 1] := X[3] {checks if I is <= 1 and adds 1 to I}

{loop}

: {index [4]= index [3]}

X[2 + 1] := X[2]

{index [3] = index [2]}

X[1 + 1] := X[1]

{index [2] = index [1]}

Am I closer? I'm supposed to show the final contents of array X after all statements execute. I just figured out that I am supposed to substitute code from one program with this code and then tell what it does. My mind doesn't even want to mess with this anymore. I have one program to finish writing and this assignment here to finish and I will earn an ass. degree in computer science, and that is what I feel like, an ass. I have until the 7th to finish but I am beginning to wonder. I think if I get a good nights sleep I'll do better tomorrow. Thanx for looking at this for me and all your help.

Serina

: X[3 + 1] := X[3] {checks if I is <= 1 and adds 1 to I}

: {loop}

: {index [4]= index [3]}

: X[2 + 1] := X[2]

: {index [3] = index [2]}

: X[1 + 1] := X[1]

: {index [2] = index [1]}

:

: Am I closer? I'm supposed to show the final contents of array X after all statements execute. I just figured out that I am supposed to substitute code from one program with this code and then tell what it does. My mind doesn't even want to mess with this anymore. I have one program to finish writing and this assignment here to finish and I will earn an ass. degree in computer science, and that is what I feel like, an ass. I have until the 7th to finish but I am beginning to wonder. I think if I get a good nights sleep I'll do better tomorrow. Thanx for looking at this for me and all your help.

: Serina

Looks good other than the part above. You got the numbers right, but the check is :

6. for I := 3 down to 1 do {initializes I to 3}

X[3 + 1] := X[3] {checks if [b]I is >= 1[/b] and adds 1 to I}

because it starts at 3 and goes down until 1

Phat Nat

Now I am supposed to use numbers from another program and say what it does and what the final outcome is.

(value of X[I] from other program)

X[1]= 16

X[2]= 12

X[3]=6

X[4]=8

X[5]=2.5

X[6]=12

X[7]=14

X[8]=-54.5

=======================================

I :=3;

X[I] := X[I] + 10;

X[I - 1] := X[2*I-1];

X[I+1] := X[2*I] + X[2*I+1];

for I := 5 to 7 do

X[I] := X[I + 1];

for I := 3 down to 1 do

X[I + 1] := X[I]

=========================================

Is this right?

I = index range

X = array

I := 3; {I = 3}

X[I] := X[I] + 10; { X[3] stores 6(from other program) + 10 = 16}

X[I - 1] := X[2*I-1]; {X[2] = X[5], X[5] = 2.5 }

X[I+1] := X[2*I] + X[2*I+1]; {X[4] = X[6] + X[7], X[4] = X[4]=26}

for I := 5 to 7 do {initializes I to 5 and checks if I>= 7

X[I] := X[I + 1];and increments with each loop}

{X[5]:= X[6], X[5] and X[6] = 12}

{X[6] := X[7], X[6]= 14}

{X[7] := X[8], X[7]= -54.5}

for I := 3 down to 1 do {initializes I to 3}

X[I + 1] := X[I]

{X[4] := X[3], X[4]= 16}

{X[3] := X[2], X[3]= 2.5}

{X[2] ;= X[1], X[2]= 16}

show final contents of array X:

X[1] = 16

X[2] = 16

X[3] = 2.5

X[4] = 16

X[5] = 12

X[6] = 14

X[7] = -54.5

X[8] = -54.5

I think I still did it wrong. I would appreciate it if you can check this for me.

Thanx, Serina

: Now I am supposed to use numbers from another program and say what it does and what the final outcome is.

: (value of X[I] from other program)

: X[1]= 16

: X[2]= 12

: X[3]=6

: X[4]=8

: X[5]=2.5

: X[6]=12

: X[7]=14

: X[8]=-54.5

: =======================================

: I :=3;

: X[I] := X[I] + 10;

: X[I - 1] := X[2*I-1];

: X[I+1] := X[2*I] + X[2*I+1];

: for I := 5 to 7 do

: X[I] := X[I + 1];

: for I := 3 down to 1 do

: X[I + 1] := X[I]

: =========================================

: Is this right?

:

: I = index range

: X = array

:

: I := 3; {I = 3}

: X[I] := X[I] + 10; { X[3] stores 6(from other program) + 10 = 16}

: X[I - 1] := X[2*I-1]; {X[2] = X[5], X[5] = 2.5 }

: X[I+1] := X[2*I] + X[2*I+1]; {X[4] = X[6] + X[7], X[4] = X[4]=26}

: for I := 5 to 7 do {initializes I to 5 and checks if I>= 7

: X[I] := X[I + 1];and increments with each loop}

: {X[5]:= X[6], X[5] and X[6] = 12}

: {X[6] := X[7], X[6]= 14}

: {X[7] := X[8], X[7]= -54.5}

:

: for I := 3 down to 1 do {initializes I to 3}

: X[I + 1] := X[I]

: {X[4] := X[3], X[4]= 16}

: {X[3] := X[2], X[3]= 2.5}

: {X[2] ;= X[1], X[2]= 16}

:

: show final contents of array X:

: X[1] = 16

: X[2] = 16

: X[3] = 2.5

: X[4] = 16

: X[5] = 12

: X[6] = 14

: X[7] = -54.5

: X[8] = -54.5

:

: I think I still did it wrong. I would appreciate it if you can check this for me.

: Thanx, Serina

Looks right, but I'm in a rush so I may have counted wrong too. But you have the idea. I'll check it again later and make another post if it is wrong.

Phat Nat

: Phat Nat,

I wanted to thank you for all your help. I finished my work and turned it in on time. I couldn't have done it without understanding this last assignment. I hope alot of good things come your way. Thanks again.

Sweet Serina

:

:

: