Computer Science Canada

How to put how many times a loop has executed in Turing?

Author:  TheMaisha [ Thu Dec 15, 2011 7:42 am ]
Post subject:  How to put how many times a loop has executed in Turing?

What is it you are trying to achieve?
I want to put how many times my loop executed

Author:  Raknarg [ Thu Dec 15, 2011 2:57 pm ]
Post subject:  RE:How to put how many times a loop has executed in Turing?

We arent going to do your homework. Have you tried anything yet?

Author:  TheMaisha [ Thu Dec 15, 2011 10:47 pm ]
Post subject:  Re: How to put how many times a loop has executed in Turing?

Obviously I have, or else why would a turn to a computer for help...

Author:  ProgrammingFun [ Thu Dec 15, 2011 11:03 pm ]
Post subject:  Re: How to put how many times a loop has executed in Turing?

TheMaisha @ Thu Dec 15, 2011 10:47 pm wrote:
Obviously I have, or else why would a turn to a computer for help...

And you obviously don't know how templates work. Do you plan on telling us what you have tried?
If not, then this is not the place to be asking this.

Author:  Zren [ Fri Dec 16, 2011 12:33 am ]
Post subject:  RE:How to put how many times a loop has executed in Turing?

The logic for counting is to set a variable to an initial value.
sum = 0

Then increment it.
sum = sum + 1 % sum=1
sum = sum + 1 % sum=2
sum = sum + 1 % sum=3

The short form for:
a := a + 1

Is:
a += 1

From this knowledge, you should be able to combine it with a loop fairly easily.

Author:  Scrubtastic [ Fri Dec 16, 2011 11:26 pm ]
Post subject:  RE:How to put how many times a loop has executed in Turing?

var a:=0
loop
a:=a+1
put a
end loop


: