Simple Programming Question: Branching in C

Discussion in 'Homework Help' started by jegues, Jan 16, 2012.

  1. jegues

    Thread Starter Well-Known Member

    Sep 13, 2010
    Hello all,

    Don't worry to much about the background of the assignement, my flowchart attached should describe well enough how the program should function.

    "Display" in the flowchart corresponds with "value" in the code.

    Basically what I want is as follows,

    While A=1, wait.

    When A = 0, execute code.

    While A is still 0, wait.

    When A=1 return to first state of waiting.

    The first and last lines of these processes is what I'm having trouble achieving.

    If I was doing this is assembly I'd simply put a branch always statement back to the first while loop and be done with it.

    How can I achieve this in C?

    I've attached my code for the flowchart on the RHS of the flowchart.

    EDIT: I fixed this problem by adding a while(1){} around my code.
    Last edited: Jan 16, 2012