Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Are there other common "c-like" or non "c-like" languages with non zero index array position? [closed]

C programming language is known as a zero index array language. The first item in an array is accessible using 0. For example double arr[2] = {1.5,2.5} The first item in array arr is at position 0. arr[0] === 1.5 What programming languages are 1 based indexes?

I've heard of the these languages start at 1 instead of 0 for array access: Algol, Matlab, Action!, Pascal, Fortran, Cobol. Is this complete?

Specificially, a 1 based array would access the first item with 1, not zero.

like image 865
Alec Jacobson Avatar asked Sep 30 '09 18:09

Alec Jacobson


People also ask

Does C++ use zero indexing?

In addition, some languages like C and C++ use pointers to store data, therefore it makes sense for indices to start at zero as well, because the memory address is held by the program counter at 0 first by default, thus making compilation easier.

Are C arrays indexed from 0?

Martin Richards, creator of the BCPL language (a precursor of C ), designed arrays initiating at 0 as the natural position to start accessing the array contents in the language, since the value of a pointer p used as an address accesses the position p+0 in memory.

Do all programming languages have arrays?

Some languages only have linked lists (for example some functional and logical programming languages). Some languages don't have arrays or lists, but are expressive enough that linked lists can be easily defined.


1 Answers

A list can be found on wikipedia.

ALGOL 68 APL AWK CFML COBOL Fortran FoxPro Julia Lua Mathematica MATLAB PL/I Ring RPG Sass Smalltalk Wolfram Language XPath/XQuery 
like image 196
LJM Avatar answered Oct 18 '22 15:10

LJM