Syntax

C++ Classic For Loop Syntax

In C++, classic for loop: loops a set number of times — for (int i = 0; i < n; ++i) { ... }

Quick Answer

Syntax
for (int i = 0; i < n; ++i) { ... }
C++Syntax

Classic For Loop

Code example
for (int i = 0; i < n; ++i) { ... }

Loops a set number of times.

Learn More

How to classic for loop in C++

  1. Open your C++ file or editor.
  2. Copy the example, then replace its sample names and values for your code.

C++ Classic For Loop Syntax

Use for (int i = 0; i < n; ++i) { ... }.

Related Syntax References

Frequently asked questions

What is the C++ syntax for classic for loop?

Use this pattern: for (int i = 0; i < n; ++i) { ... }

Can I copy this C++ code example?

Yes. Use Copy code and adapt the example to your program.

Is this C++ syntax different on Mac or Windows?

No. The language syntax is the same across operating systems.

Official source · How we verify