FreePrograms


 

C language is a middle level language. It is a structured language. C language is a case sensitive language. All syntax written in c language is in lower case. C is the basis for C++.
  CONTACT US   ABOUT US   PRIVACY  DISCLAIMER

FREE C PROGRAMS 

What is C C vs C++ vs Java Program Structure Data Types in C Basic Rules of C & C++
Functions in C If, Else Conditions Loops in C Switch Case Arrays
Pointers Structures in C Strings in C Command Line Arguments Type Casting
Linked Lists Recursion Binary Trees Inheritance Multiple Inheritance
Templates File I/O Object Oriented Programming Data Structures in C C interview Questions
.

Arrays in C: - C Programming Tutorial




Array can be easily defined as a variable that hold multiple elements which has the same data type. C uses arrays as a way of describing a collection of variables with identical properties.

type variable_name[lengthofarray];

Simple Program showing an array of 5 elements.

In this case we have ages[5] as an array. i.e ages[0],ages[1],ages[2],ages[3],ages[4].

Example of Array Declaration:

double arr[100]

Another example :

int myArray[5] = {1, 2, 3, 4, 5}; //declaring and initialize the array in one statement
int number[4];
number[0]=14;
number[1]=13;
number[2]=15;
number[3]=16;

Declaration of a 2D array in C language:

int x[3][2] - matrix 3X2 (3 rows, 2 columns(

Example:

int array[3][3] = {1, 2, 3, 4, 5};
array[0][0] = 1
array[0][1] = 2
array[0][2] = 3
array[1][0] = 4
array[1][1] = 5
array[1][2] = 0
array[2][0] = 0
array[2][1] = 0
array[2][2] = 0

 

See this program of Matrix Multiplication using the concept of Arrays.

Matrix Multiplication

Multiplying Matrices with Each Other.