How you can use array in c language?

1 answer

Answer

1250591

2026-07-23 23:45

+ Follow

An array is a contiguous block of memory containing one or more elements of the same type and size. Each element in the array is accessed as a zero-based offset from the start of the array or by using the index [].

Examples:

int a[10]; // allocates memory for 10 integers (e.g., 40 bytes for a 4 byte int).

int x = a[5]; // accesses the 6th element (a[0] is the first element).

int *p = a; // point to start of the array.

p += 5; // advance pointer 5 * sizeof( int ) addresses.

*p = 10; // access the 6th element and assign the value 10.

int d * = new int[*p]; // dynamically allocate an array of 10 elements.

delete [] d; // release dynamic array.

ReportLike(0ShareFavorite

Copyright © 2026 eLLeNow.com All Rights Reserved.