Math Is Fun Forum

  Discussion about math, puzzles, games and fun.   Useful symbols: ÷ × ½ √ ∞ ≠ ≤ ≥ ≈ ⇒ ± ∈ Δ θ ∴ ∑ ∫ • π ƒ -¹ ² ³ °

You are not logged in.

#1 2011-04-24 14:10:48

mantastrike
Member
Registered: 2011-04-24
Posts: 64

Please help me with this trace table!

Make a trace table to trace the action of the following loop?


a: = 3, b: = 3
for c: = 1 to 4
b: = b ∙ c
a: = a + c
next c

Offline

#2 2011-04-24 15:14:32

bobbym
bumpkin
From: Bumpkinland
Registered: 2009-04-12
Posts: 109,606

Re: Please help me with this trace table!

Hi mantastrike;

You will never learn how to program a computer if you have some one else do your work for you. This is a very easy problem. Never mind that this method of trace tables is a very poor method. You must do your own work. For the last week and a half all I have heard is "Oh, I am never going to use math in my job, so why do I have to learn it?" If that argument is spurious for mathematics it is doubly spurious for programming. You must make an effort!


In mathematics, you don't understand things. You just get used to them.
If it ain't broke, fix it until it is.
Always satisfy the Prime Directive of getting the right answer above all else.

Offline

#3 2011-04-24 22:32:42

mantastrike
Member
Registered: 2011-04-24
Posts: 64

Re: Please help me with this trace table!

THANK YOU THANK YOU VERY MUCH MAN!!

If possible can you please tell me how you got this? in detail please. THANKS!!

Yeah I know, but there are a lot of thing going on so I was not able to do this.

Offline

#4 2011-04-24 23:21:17

bobbym
bumpkin
From: Bumpkinland
Registered: 2009-04-12
Posts: 109,606

Re: Please help me with this trace table!

Hi mantastrike;

There is no need to thank me. I am here to help, you have asked so I will. Because you are a polite and obviously thoughtful person I am making an effort to change your mind.

Yeah I know, but there are a lot of thing going on so I was not able to do this.

You are placing minutiae ahead of your studies. Ahead of your future. Ahead of your potential. Whether it is a girl, partying or even a job, it takes second to your education. Believe me I know. I am going to do my best now to get you through but someday you will wish I did not.

A program is a series of instructions you give to a computer. Modern machines are basically sequential devices that means they do one thing at a time. Code runs line by line, one instruction at a time, from top to bottom.

Start:

a: = 3, b: = 3

These 2 instructions store the value of 3 into a and then b.

for c: = 1 to 4

This instruction is called a for next loop. It starts by initializing some variable with a beginning value (1) and an end value (4). This loop starts with c = 1.

b: = b ∙ c
a: = a + c

These 2 instructions are the body of the loop.

The first one says take what is in b (3) and multiply it by what is in c (1) and store it back into b

The second one says take what is in a (3) and add to it by what is in c (1) and store it back into a

next c

This last statement says add one to c and check whether is greater than 4. If it is not then it will go back to the for c = 1 to 4 statement (underlined ). If it is greater than 4 then the program ends.

What I have done above is called pseudocode. It is mixed english, programming and math.

If you run through the statements that I have given you above and write down the values for c, a, and b you will get the trace table.


In mathematics, you don't understand things. You just get used to them.
If it ain't broke, fix it until it is.
Always satisfy the Prime Directive of getting the right answer above all else.

Offline

Board footer

Powered by FluxBB