My loop is not adding anything to my list - list

Within my program for my TI 83 Plus, I have a loop that is supposed to add random integers to my list, yet it is not working, here is my code:
0->I
While I<10
I+1->I
augment(⌞X,{RandInt(0,52))})
End
Disp (⌞X)
Pause
The program ends up just printing {0} Can anyone tell me where I'm going wrong?

Related

Why this loop of searching in lnked list runs infinitely?

I am a beginner C programmer. I cant understand why the program goes into an infinite loop and print "The key element is not found". It may be a trivial error. Please help me.This program is to delete a node of a linked list
The program code is avalible here.
https://repl.it/#sandipanman/Linkeddel

how to get a block of code to run only once in a loop in fortran in a case where the condition repeats

I am running a program in fortran 95. The loop contains a set of conditional actions that reverses under set limits. Please can someone advise me on how to get a block of code to run only once in a loop, such that it does repeat when the condition is met, but runs the rest of the code until the number of iterations is complete?
After reading your question several times, I think I know what you want. If you want a piece of code to always run at least once inside a do loop but possibly repeat, you can try something like this. Start with a logical variable to ensure one execution:
once = .true.
do i = 1, whatever
some code
if (once .or. (another condition)) then
once = .false.
code will always run once but possibly repeat
end if
can have more code
enddo

Continue an iteration in C++ until a specific iteration number in gdb

I am using gdb-7.0.1 and I think I have detected a bug in a certain section of my code, which
has a for loop. The for loop looks like
for (int i=0 ; i< end ; ++i )
{
//Code here.
}
Here end is a very large integer. The code does not crash at the first iteration, and seems to crash somewhere at iteration number end/2.
Since I want to understand the behaviour of the code at iteration number end/2 , just stepping and nexting from i=0 till I reach this iteration point, is unfeasible.
Is there a way to tell gdb to continue through a for loop till i gets the value end/2 and then wait for the user to manually step through iteration number end/2?
I am using gcc-4.5.2 on Ubuntu Linux
Here's a tutorial on conditional breakpoints with gdb.
I'm guessing you didn't know the term for this, otherwise it would have been easy to google.
When you set the breakpoint it'll give you a breakpoint number (for the moment, let's assume it's 1). You'll then make that breakpoint conditional, something like:
condition 1 i==end/2
You have to use conditional breakpoint. Here is more about it: http://www.cs.cmu.edu/~gilpin/tutorial/#3.4
And on SO: How do I set a conditional breakpoint in gdb, when char* x points to a string whose value equals "hello"?
In your case (not tested):
break <line_number> if i==end/2
You should be able to place an if (i == (end/2 -1)) { Foo; } in there then set a breakpoint at Foo, which would allow you to continue stepping from there.
If end is big (in the tens of thousands), then the conditional breakpoint solution can be very slow - gdb has to evaluate the condition each time round the loop. If this is a problem for you, then you can use this trick:
for (int i=0 ; i< end ; ++i )
{
if (i == end/2)
i %= end ; // This has no effect, but lets you set a breakpoint here
//Code here.
}
I do this all the time :-)
Another solution is to set a skip-count on the breakpoint. I use gdb in a Qt environment, so I can't give you the gdb syntax. But it's faster than setting a condition.

Is it possible to skip over an abitrary amount of a loop during debug?? Visual Studio

I am trying to find an error in my code. The problem is the error occurs in a loop. But the loop iterates about 500 times. Instead of clicking through the loop. Is it possible to skip over a certain amount of the loop ??
VS allows you to set a condition on a breakpoint in terms of variables that are in scope. So, in your case, you can test against the loop counter.
Here is a crude answer:
if ((iter % 10) == 0) {
int stop = 1;
}
Then place a break-point at "int stop = 1;". Perhaps, there is a better way in VS but this is what I do from time-to-time.
You can assign new values to variables during debug session. Step through the loop statements as many times as you like, then set your loop counter (or whatever other vars maintain loop condition) to terminate the loop.
Just put the breakpoint in the loop like indicated below >>. Use F5 to get to the condition that causes failure so you can loop through the individual pass. How to know where to break is up to you.
for (int i = 0; i < LOOPMAX; i++) {
>>some_proc(i);
some_other_proc(i);
some_third_proc(i);
}
By pressing F5 it'll continue running till it gets to the next breakpoint (the next pass through the code). Sure you'll have to hit it 500 times, but that beats some thousands of times. Combine this with #Troubador code above.
PS: This answer IS really simple, but some people don't know they can do this.

Syntactical analysis with Flex/Bison part 2

Hallo,
I need help in Lex/Yacc Programming. I wrote a compiler for a syntactical analysis for inputs of many statements. Now i have a special problem.
In case of an Input the compiler gives the right output, which statement is uses, constant operator or a jmp instructor to which label, now i have to write so, if now a if statement comes, first the first command (before the else) must be give out when the assignment of the if is yes then it must jump to the end because the command after the else isnt needed, so after this jmp then the second command must be give out. I show it in an example maybe you understand what i mean.
Input adr. Output
if(x==0) 10 if(x==0)
Wait 5 20 WAIT 5
else 30 JMP 50
Wait 1 40 WAIT 1
end 50 END
like so. I have an idea, maybe i can do it whith a special if statement like
IF exp jmp_stmt_end stmt_seq END
when the if statement is given in the input the compiler has to recognize the end ofthe statement and like my jmp_stmt in my compiler ( you have to download the files from http://bitbucket.org/matrix/changed-tiny) only to jump to the end. I hope you understand my problem.thanks.
I would do this by a two-stage output: the first pass wold generate a list with each output statement, where the jump targets are encoded by labels, and a second pass, where this list is used to generate the real output. Something like this:
pass one:
Number Label Satatement
10 if(x==0)
20 WAIT 5
30 JMP (A)
40 WAIT 1
50 A END