0

Apologies ahead of time, I don't fully understand what I'm asking...

But, is it possible to program using only 'while loops' and still be Turing equivalent?

Or more generally, can I do everything with 'while loops' that I could with 'if statements' and 'for loops'?

XYZandMe
  • 15
  • 3

1 Answers1

0

for(X; Y; Z) { Body; } is just syntax sugar for {X; while (Y) { Body; Z; }}.

if can be simulated easily: rewrite if (X) { Body; } as while (X) { Body; break; }.

Peter Taylor
  • 2,082
  • 10
  • 15