• TestingDocs
TestingDocs.com
Software Testing website
  • Automation
    • Selenium
    • JBehave Framework
  • Tutorials
    • MySQL Tutorials
    • Testlink
    • Maven
    • Git
  • IDEs
    • IntelliJ IDEA
    • Eclipse
  • Flowcharts
    • Flowgorithm
    • Raptor
  • About

C Tutorials

C Arrays

Overview

In this tutorial, we will learn about C Arrays. An array is a collection of elements of the same data type stored in continuous memory locations.

Declare Array

The general syntax to declare an array is as follows:

<data type> <array name> [size];

For example, to declare an array to store six integer numbers:

int numbers[6];

The numbers array is of a single dimension or 1D array.

Declare C Arrays

In this statement, we have declared the array and have not initialized the array elements.

Array Initialization

We can also initialize the fixed length array during the array declaration as shown below:

Example

int numbers[6] ={4,7,9,12,34,46};

 

C Array Initialization

An array is a data structure of multiple elements with the same data type. Array elements are accessed and stored using the array index.

The memory allocation of the array in the example would be as shown below:

 

C Arrays Illustration

In C language, the array index starts with 0. The first array element can be accessed using

numbers[0]

The valid range of the index is 0 to size – 1.

Related Posts

C Language Characteristics

C Tutorials /

C Language Characteristics

C Source Code .c File

C Tutorials /

C Program Files & Formats

GNU Compiler Collection GCC

C Tutorials /

C Compilers

C Pointers

C Tutorials /

C Pointers

C Tutorials /

C Two-Dimensional Arrays

‹ User-Defined Functions in C› C Two-Dimensional Arrays

Recent Posts

  • How to secure your SQL Database: Tips and Tricks
  • Shaping the Future of Development: Exploring Key Trends in Software Engineering
  • Improving Java Performance with Multithreading
  • Difference between PHP and JavaScript?
  • Bing Conversation Styles
  • ChatGPT Introduction
  • Open Source AI Frameworks
  • Artificial Intelligence Tools
  • Top AI Music Applications
  • Top AI Website Design Tools

Back to Top

Links

  • Contact
  • Privacy Policy
  • Cookie Policy

www.TestingDocs.com