बिजनेस मार्केटिंग का लो कॉस्ट फंडा , अपने मोबाइल से ऑटो sms भेजकर मार्केटिंग करे विजिट करे http://autotextsms.com/ बिजनेस मार्केटिंग का लो कॉस्ट फंडा http://autotextsms.com/

Search This Blog

Translate

Explain Array in c, its type how to use array with function and pointers

types of arrays in c,array in c programming,arrays in c,two dimensional array in c example of array in c, arrays in c with examples,array examples in c, what is array in c with example,array in c with example,two dimensional array in c example,examples of arrays in c,examples of array in c,array in c examples, array of structures in c example,one dimensional array in c example, 2d array in c example, explain two dimensional array with example, two dimensional array example in c, multidimensional array in c with example, example of two dimensional array in c, 2 dimensional array in c example, about arrays in c, multidimensional arrays in c, what is 2d array in c, pointers to array in c




Explain Array in c

Array by definition is a variable that hold multiple elements which has the same data type.Array is variables that hold multiple elements which has same data type.
An array is a multi element box, uses an indexing system

Declaring the array:  We can declare an array by specify its data type, name and the number of elements the array holds between square brackets immediately following the array name. Name;

Type of array
Number of element  "data type array name[size];"

There are some rules on array declaration. 

The data type can be any valid C data types including structure and union. The array name has to follow the rule of variable and the size of array has to be a positive constant integer.We can access array elements via indexes array_name[index]. Indexes of array starts from 0 not 1 so the highest elements of an array is array_name[size-1].

Initializing the array: 

It is like a variable, an array can be initialized. To initialize an array, you provide initializing values which are enclosed within curly braces in the declaration and placed following an equals sign after the array name.
int list[5]={2,3,4,5,6} OR  int list[5] = {2,1,3,7,8};

Character arrays:  

 char string1[]=”first”;, "Here ,we using char string and its array size is six."
char string[]={‘f’,’g’,’t’,’y’,’u’,’I’,’\0’};    //  \0 null character terminating the string.

Passing the array  

  To pass an array argument in a function specifies the name of array to pass without any bracket.
intmyarray[24];
myfunction(my array,24).
• array usually pass to the function
• array using call by refrence
• function knows where the array stored

Passing array element:

• using call by value
• pass subscripted name (ex: myarray[5]) to function.

Function prototype: 

void modify array (intb[],int array size);
Parameter name may be optional.
int b[] may be int[]
int array size may be int

Multidimensional Array:

 An array with more than one index value is called a multidimensional array. All the array above is called single-dimensional array. To declare a multidimensional array you can do follow syntax
data_typearray_name[][][];
The number of square brackets specifies the dimension of the array. For example to declare two dimensions integer array we can do as follows:
1. intmatrix[3][3]; 

Initializing Multidimensional Arrays

you can initialize an array as a single-dimension array. Here is an example of initialize an two dimensions integer array:

1. int matrix[3][3] =  { {11,12,13},
 {21,22,23},
{32,31,33},
 };

 Two dimensional arrays

Multidimensional array have two or more than indexs values which specify the element in the array. i.e., multi[i][j].
Where [i] specify row and [j] specify column
Declaration and calculation:
int a[10][10];
int b[2][2];   // int b [2][2]={{0,1},{2,3}}
Sum = a[10][10]+b[2][2]

Array and Pointer

Each array element occupies consecutive memory locations and array name is a pointer that points to the first element. Beside accessing array via index we can use pointer to manipulate array. This program helps you visualize the memory address each array elements and how to access array element using pointer.
#include
  void main()
 { 
constint size = 5; 
int list[size] = {2,1,3,7,8}; 
 int* plist = list;
 // print memory address of array elements
 for(int i = 0; i  {
 printf("list[%d] is in %d\n",i,&list[i]);
 } 
 // accessing array elements using pointer
 for(i = 0; i  {
 printf("list[%d] = %d\n",i,*plist); 
 /* increase memory address of pointer so it go to the next
 element of the array */
 plist++;
. }}
Here is the output
list[0] is in 1310568
list[1] is in 1310572
list[2] is in 1310576
list[3] is in 1310580
list[4] is in 1310584
list[0] = 2
list[1] = 1
list[2] = 3
list[3] = 7
list[4] = 8
You can store pointers in an array and in this case we have an array of
pointers. " int *ap[10];" 



types of arrays in c,array in c programming,arrays in c,two dimensional array in c example of array in c, arrays in c with examples,array examples in c, what is array in c with example,array in c with example,two dimensional array in c example,examples of arrays in c,examples of array in c,array in c examples, array of structures in c example,one dimensional array in c example, 2d array in c example, explain two dimensional array with example, two dimensional array example in c, multidimensional array in c with example, example of two dimensional array in c, 2 dimensional array in c example, about arrays in c, multidimensional arrays in c, what is 2d array in c, pointers to array in c

C Program example List