Skip to content
doubtly

2 answers

Answer: data_type array_name[size];

  • data_type: type of every element (int, float, char, ...)
  • array_name: any valid identifier
  • size: number of elements, a positive integer constant

Examples:

int a[10];                    /* 10 integers: a[0] to a[9] */
float price[5];               /* 5 floats */
int b[4] = {2, 4, 6, 8};      /* declaration with initialisation */
char name[20];                /* string of up to 19 characters + '\0' */

Indices run from 0 to size - 1. When the array is initialised, the size can be left out, e.g. int b[] = {2, 4, 6, 8};, and the compiler counts the elements.

Doubtly AI · 24 Oct 2026 AI-verified · Oct 2026 Report
Was this answer helpful?

Your answer

Log in or create a free account to answer this question.