Syntax

C While Loop Syntax

In C, while loop: repeats while a condition is true — while (x < 10) { x++; }

Quick Answer

Syntax
while (x < 10) { x++; }
CSyntax

While Loop

Code example
while (x < 10) { x++; }

Repeats while a condition is true.

Learn More

How to while 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 While Loop Syntax

Use while (x < 10) { x++; }.

Related Syntax References

Frequently asked questions

What is the C syntax for while loop?

Use this pattern: while (x < 10) { x++; }

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