Is C++ a turing complete language?

Viewed 1849

Is C++ a turing complete language?

Obviously that would be the case, but how is it proven practically?

Is there a minimally reproducible example that shows that this is the case?

2 Answers

Yes it is, from wikipedia Turing completeness

To show that something is Turing-complete, it is enough to show that it can be used to simulate some Turing-complete system. For example, an imperative language is Turing-complete if it has conditional branching (e.g., "if" and "goto" statements, or a "branch if zero" instruction; see one-instruction set computer) and the ability to change an arbitrary amount of memory (e.g., the ability to maintain an arbitrary number of data items).

Then imperative languages lists C++ as such.

I'm not an expert of computational theory but as empirical law a language is declared Turing-complete if it supports conditional branching, i.e. it must support if statements and go-to instruction. So the majority of languages out there is Turning-complete.

Ref. https://en.m.wikipedia.org/wiki/Turing_completeness

Related