Syntax

C Declare an Array Syntax

In C, declare an array: declares a fixed-size array — int nums[5] = {1, 2, 3, 4, 5};

Quick Answer

Syntax
int nums[5] = {1, 2, 3, 4, 5};
CSyntax

Declare an Array

Code example
int nums[5] = {1, 2, 3, 4, 5};

Declares a fixed-size array.

Learn More

How to declare an array in C

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

C Declare an Array Syntax

Use int nums[5] = {1, 2, 3, 4, 5};.

Related Syntax References

Frequently asked questions

What is the C syntax for declare an array?

Use this pattern: int nums[5] = {1, 2, 3, 4, 5};

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