how to implement IF and IF-else condition in brainf##k language and how to compare two values at different location say at cell 1 and cell 4
thanks in advance

  • created

    May '14
  • last reply

    Jul '14
  • 1

    reply

  • 568

    views

  • 2

    users

1 month later

All if-else decisions are based on the value of the condition.It is either zero or a non-zero value.
If-else in BF could be achieved by setting a cell to zero/non-zero value.I think an example would do just fine here. Here, let us try printing '1' if value in cell-1 is non-zero ,else '0'. Let cell-2= '0' and cell-3= '1'

[color=#FF0000][>[-]]>.[/color] [color=#008040] #only if cell-1 is non-zero the loop(bracket) will be taken and the next cell set to null[/color]

In general, the first cell would serve as the "condition".