Skip to main content

Posts

Showing posts with the label Array and Pointers in C

Array and Pointers in C

Pointers and arrays are inseparably related, but they are not synonymous. An array is a non empty set of sequentially indexed element having the same type of data. Each element of the array has a unique identifying index number. Changes made to one element do not affect the other elements. An array occupies contiguous block of memory. Array notation(int a[10]) is a form of pointer notation. The name of an array is the beginning address of the array, called the base address of the array. It is the address of the zeroth element of the array. The array name is the address constant .So *a will get the zeroth element and *(a+1) will get you the first element and so on.The indirection operator * implies that value at address a[i] is equivalent to *(a+i). Execute this program to know the concept #include <stdio.h> int main() { int a[]={10,20,30,40,50}; printf(“%d %u %u %d %u %u %d”,a[0],a,&a[0], *a,&a[1],(a+1),*(a+1)); } Note that a[0] and *a will print the ze