arrays in c

 

  • What is Arrays
  • Declaring Array
  • One Dimensional Array
  • Array Initialization and Sub scripting
  • Examples Using One Dimensional Array
  • Two Dimensional Array
  • Initializing a 2-D Array
  • Examples Using Two Dimensional Array


 
Array:

  1. The C language provides a capability that enables the user to design a set of similar data types, called array.
  2. Ordinary variables can only hold one value at a time; however, an array can store more than one value at a time.
  3. An array is a collective name given to a group of ‘similar quantities.



An array is a variable that can store the same type of multiple values. For example, if you want to store 50 integers, you can create an array for it.

 

 

int numbers[50];


Declaring Arrays:

Name
Type of array
Number of elements
 
arrayType arrayName[ numberOfElements ];

Examples:  
 
int c[ 10 ];  
float myArray[ 100 ];


Initializing Arrays:

int c[ 5 ] = {10, 5, -7, 8, 2};  
int c[ ] = {10, 5, -7, 8, 2};
Next Post Previous Post
No Comment
Add Comment
comment url