CoolInterview.com - World's Largest Collection of Interview Questions
Send Free SMS
 Interview Questions  
 Our Services  


INTERVIEW QUESTIONS LANGUAGES C DETAILS
Question :
Difference between arrays and pointers?
Category C Interview Questions
Rating (3.8) By 142 users
Added on 10/22/2004
Views 27318
Rate it!
Answers:

Pointers are used to manipulate data using the address. Pointers use * operator to access the data pointed to by them<br><br>Arrays use subscripted variables to access and manipulate data.Array variables can be equivalently written using pointer expression.



DIFF BETWEEN ARRAY AND POINTER<br>Pointers are used to manipulate data using the address. Pointers use * operator to access the data pointed to by them<br><br>?Arrays use subscripted variables to access and manipulate data.Array variables can be equivalently written using pointer expression. <br>? CoolInterview.com<br><br><br><br>



 Posted by: DHARAM PAL    

Contact DHARAM PAL  Contact DHARAM PAL

Pointers are used to manipulate data by using address or they are address variable used to store address.Pointers use * operator to access data.<br>Array are used to store data of same data type and they are denoted or stored by same name.They use continuous memory allocation and use subscripted variables.Eg int A[50]<br>'A' is name of array which can store 50 data of integer type and denoted by A[0]A[1]...A[49].



 Posted by: Priyanka Dutta    

Contact Priyanka Dutta  Contact Priyanka Dutta

Pointers are used to manipulate data by using address or they are address variable used to store address.Pointers use * operator to access data.<br>Array are used to store data of same data type and they are denoted or stored by same name.They use continuous memory allocation and use subscripted variables.Eg int A[50]<br>'A' is name of array which can store 50 data of integer type and denoted by A[0]A[1]...A[49].



 Posted by: Priyanka Dutta    

Contact Priyanka Dutta  Contact Priyanka Dutta

pointer are stored a memory location of any other variable.<br>and array is a group memory cells.which stored a data per cell.



 Posted by: vijay sharma    

Contact vijay sharma  Contact vijay sharma

Difference between Array and Pointer -<br><br>Array:<br><br>int ar[10] - Arrays are fixed size and address that 'ar' holds can not be changed it is fixed throughout the scope.<br><br><br>Pointer: <br><br>int *P = (int *)malloc(sizeof(int)*10);<br><br>above statement will alocate an memory of type integer and data holding capacity is 10.<br><br>free(p); // free allocted memory.<br><br><br>p = (int *)malloc(sizeof(int)*20);<br><br>now here we are changing 'size as well as value of 'p' that is address hold by 'p' as weell.<br><br>Pointers provide flexible way to deal with run time allocations.<br><br><br>Also you can perform '++' operation on pointer ( p++ ) but you can not perform '++' operation on Arrays. ( ar++ ia an error! ).<br><br><br><br><br>



 Posted by: Prasad    

Contact Prasad  Contact Prasad

array s are constant pointers, the address of starting element would be stored in name of array. whose position cannot be changed <br><br>ordinary pointer contains address of any element and the address what it has can be changed



 Posted by: hari babu    

Contact hari babu  Contact hari babu

Arrays are call to the pointers by using the symbol ->(arrow). <br> pointers are used * operatur to access the data &also pointed to the address.



 Posted by: chunduri Indira    

Contact chunduri Indira  Contact chunduri Indira

?Pointers are used to manipulate data using the address. Pointers use * operator to access the data pointed to by them<br><br>?Arrays use subscripted variables to access and manipulate data.Array variables can be equivalently written using pointer expression.<br><br>DIFF BETWEEN ARRAY AND POINTER<br>Pointers are used to manipulate data using the address. Pointers use * operator to access the data pointed to by them<br><br>?Arrays use subscripted variables to access and manipulate data.Array variables can be equivalently written using pointer expression.<br><br>



 Posted by: nithyaraj    

Contact nithyaraj  Contact nithyaraj

Pointers are used to manipulate date using thir address location which gives high speed process of performance level.<br><br>Array is collection of data elements represent as sequancial order. if you using pointer traverse the array with minimal changes of address location bacause of subsequent address of data stored



 Posted by: vijay    

Contact vijay  Contact vijay

Arrays-Array is a set of Similar data types, It is collection of similar Elements Stored In Contigous form In memory And Each element has Some adress. <br>Pointers - Pointers are Basically Used to acess To the adress OF the Elements Stored In Memory. It is also Used to acess to the element in the array as well as adress of the element in that array.



 Posted by: Rahul    

Contact Rahul  Contact Rahul

Pointer is a variable that store adress of other variable.<br>Array is a subscripted variable that store similar type of data set.



 Posted by: sourav    

Contact sourav  Contact sourav

Pointer can point to different memory location where array contains contigious memory.



 Posted by: konica    

Contact konica  Contact konica

pointer is use to access the data with its address. and<br>array is the collection of similar data for access and manipulate.



 Posted by: vaibhav saxena    

Contact vaibhav saxena  Contact vaibhav saxena

Actually Pointers are used to manipulate data using the address. Pointers use * operator to access the data pointed to by them<br><br>Arrays are used to manipulate multiple values of same kind of data without declaring and assigning them individually. The important point to be noted is that while programming, pointer indirections can be achieved by array notations and vice-versa. For example, class[60] is exactly equivalent to *(class+60). This may lead some beginner programmrs to think that pointers and arrays are euivalent, but they are equivalent only to the parser, the programmer need not be concerned about whether they are equivalent or not.



 Posted by: Swagato Barman Roy    

Contact Swagato Barman Roy  Contact Swagato Barman Roy

By-default the array variablr is const pointer.<br><br>int arr[10];<br><br>where arr is const pointer (i.e. always pointing to fixed address)<br><br>While a pointer can point to any address of it's type.



 Posted by: Ramakant    

Contact Ramakant  Contact Ramakant

Arrays just like normal variables only. They can be effected directly as we modify variables.<br>But pointers are can be modified by modifying their address only



 Posted by: sanjaykumar    

Contact sanjaykumar  Contact sanjaykumar

ARRAY is a collection of similar data types.<br>Elements of an array occupy adjacent memory location in RAM.<br>For Eg.. <br>int a[5];<br>An integer type array that can store 5 elements is created.<br><br>A POINTER is a special kind of variable that stores the address of other variabes.<br>It is denoted by *<br>For eg.. *ptr



 Posted by: Ankita Leekha    

Contact Ankita Leekha  Contact Ankita Leekha

An array is a structer that can store several elements sequantialy in memory.Array index number start with 0.<br>Pointer is store memory address of another variable.Pointer is declared with * operator.



 Posted by: Deepak Bankar    

Contact Deepak Bankar  Contact Deepak Bankar

arrays:<br>1.array is a constant pointer,which is having base address.<br>2.we will use subcripts to access the<br> array variables<br>pointer:<br>1. pointer is variable address.<br>2. pointer use indirection operator<br> to access array elements<br>



 Posted by: harsha    

Contact harsha  Contact harsha

Array is a constant pointer.<br>we con't change base address of array.



 Posted by: vinod kumar    

Contact vinod kumar  Contact vinod kumar

In case of passing parameter to the function, pointer holds the address of orginal array and changes will be donein same array.<br><br> but passing array parameter needs a another copy of same size array at calling function and it will not reflect the change to the original array. .



 Posted by: SAngeeta SAngani    

Contact SAngeeta SAngani  Contact SAngeeta SAngani

A pointer is an address in memory where a variable is located. <br><br>An array is a conceptual data representation consisting of a list of more than one item of a particular scalar type (int, float, char, structure, etc.) where each element is accessed by its index. The index can be thought of as a counter or enumerator telling you how many elements you have to skip over to get to the one you're interested in. Here's where addresses come in ... the location of a particular element in memory is offset from the so-called base address (i.e. the address of the starting element) by the value <br><br>(sizeof(one element) * index #) <br><br>The C compiler is smart enough to take the sizeof() into account when you do pointer arithmetic, so you can find the address of the i-th element as (address of base) + i, rather than having to do the multiplication explicitly. <br><br>The idea of element address as offset also accounts for C's use of zero-relative array definitions. Since the first element is offset by 0 positions from the first element its index in C is 0, not 1. The second (ordinal) element is offset from the first by 1 position so its index is 1, and so on



 Posted by: jayant gurjar    

Contact jayant gurjar  Contact jayant gurjar

pointers are used to point to storage indirectly through * operator.<br>arrays are used for contiguous storage of data which can be accessed by the starting address of the array.<br>compiler also treats array data using pointers. for ex: if 'a' is an array with subscript 'i' , then ith element is treated as *(a+i) by compiler.



 Posted by: chaitu    

Contact chaitu  Contact chaitu

An array ar[15][23]is stored inmemory along the column with each of element occupying 8byte. find oyt the base adress and the adress of an element arr[23]21],if the location arr[12]23]is stored at the adress4000.



 Posted by: haripaloraon    

Contact haripaloraon  Contact haripaloraon

Array is a collection of same data type. <br><br><br>Pointer is used to refer the address.pointer value refered by &.<br><br>



 Posted by: shanthi    

Contact shanthi  Contact shanthi

Arrays are basically pointers BUT the difference is that arrays are constant pointers and so we cannot do pointer arithmatic with arrays as we do with other pointers. <br><br>ie; ArrName++ or ArrName-- is not possible in the case of arrays while it is possible for pointers



 Posted by: Lily Antony    

Contact Lily Antony  Contact Lily Antony

In actual there is no difference between arrays and pointers.<br>It is only that they are different in manners they are declared and accesed by the programmer.<br>for example <br>int a[3]= {<br> 1,<br> 2,<br> 3<br> }<br>This is same as int *p;<br> *p = 1;<br> *(p+1) = 2;<br> *(p+2) = 3;<br><br>If you want to print 2<br>for the 1st case write<br>printf("%d",a[1]);<br>for the 2nd case write<br>printf("%d",*(p+1));



 Posted by: vallari    

Contact vallari  Contact vallari

Pointer is used to store address of a variable(Variable contains the value).Pointer is denoted by * before a variable.<br>Where as Array is a collection of variable of similar type and it may be of differnt dimentions example array of 1 dimention = ar[],array of 2dimention[][] and so on.



 Posted by: Sumit    

Contact Sumit  Contact Sumit

The array size depends on the datatype and on the subscipt value.<br>Array representation is very easy to understand <br><br><br>Pointer is always of constant 2 bytes irrespective of the datatype it is pointing to........<br>Pointers occcupy less memory space...



 Posted by: Subrahmanya    

Contact Subrahmanya  Contact Subrahmanya

The main diff. w/b array and pointer.<br> array is a simler collection of number or char. while pointer is a variabile whish point the memory of the variabile.



 Posted by: abhishek shukla    

Contact abhishek shukla  Contact abhishek shukla

In Array, each Time, The comiler allocates the memory To maximum Elements or to full size of the array. Suppose If User wants To Use only 5 elements at a time From 20 elements of declared Size of the array. It wastes 15 allocated Location in the Memory,,,,, Pointers Remove This disadvantage , With Malloc, n calloc, Pointers Allocates The desired Memory To the variable or Elements of the array,,



 Posted by: Rahul    

Contact Rahul  Contact Rahul

Pointer is a variable capable of storing address of another variable.<br><br>Array is a data type which is used to store group of variable of same type



 Posted by: pratyasini satapathy    

Contact pratyasini satapathy  Contact pratyasini satapathy

ARRY : Arry is the collection of similar data types.<br>POINTER : Pointer is the variable which stores the value of another varible



 Posted by: Amol Patil    

Contact Amol Patil  Contact Amol Patil

POINTER : pointer is a variable dat is used to store an address of any variable in order to call it by adderss.<br>ARRAY: array is a datastructure havin similar datatypes<br><br>NOTE:The name of any array is a pointer.



 Posted by: pravat kumar sahoo    

Contact pravat kumar sahoo  Contact pravat kumar sahoo

array is group of collection of data of same type <br><br>pointer is to store the reference of another variable



 Posted by: sridhar    

Contact sridhar  Contact sridhar

pointers are nothing but a memory location which points the desired variable.<br>Array is a contiguas memory location having same data type.



 Posted by: Harendra kumar    

Contact Harendra  kumar  Contact Harendra kumar

pointer: it is an address of a variable<br><br><br><br>array:it is a continuous memory location where similar type of data is stored



 Posted by: swathi reddy    

Contact swathi reddy  Contact swathi reddy

Pointer is a variable capable of storing address of another variable.<br><br>Array is a data type which is used to store group of variable of same type <br><br><br>



 Posted by: gopi    

Contact gopi  Contact gopi

Pointer is a variable, which stores Address of Another variable. And * operator is used to assess the data within it.<br><br>Whereas Array is group of variables having consecutive allocation of memory ended with NULL of similar data type.



 Posted by: Basavaraj Hunshal    

Contact Basavaraj Hunshal  Contact Basavaraj Hunshal

ARRAY:It is a collection of all data items which can be stored at same location.<br>pointer: pointer is a variable which stores the address of another variable.



 Posted by: krishnachaitanya    

Contact krishnachaitanya  Contact krishnachaitanya

array:array is a collection of data items which can be stored at same location.<br>pointer:pointer is a variable which stores the address of another variable.



 Posted by: krishnachaitanya    

Contact krishnachaitanya  Contact krishnachaitanya

ARRAY:array works as a contaner that contains the variable of same type.<br>POINTERT:It also work as a container that contains the address of another variable.



 Posted by: Naina Verma    

Contact Naina Verma  Contact Naina Verma

array and pointers both are used to store but one stores data and the other stores address<br>also its easy to get or delete or search information if we use pointers but in arrays its very difficult and time consuming



 Posted by: deepa dev    

Contact deepa dev  Contact deepa dev

ARRAY:array is a collection of homogeneous data elemens.which are stored in buffer memory location.<br>POINTER:pointer is a variable which holds the address of another variable.it is easy to access the variable addrress and content in our program.



 Posted by: LAXMAN HONAWAD    

Contact LAXMAN HONAWAD  Contact LAXMAN HONAWAD

pointer:- it is store the variable address to assign by astrick symbol.<br>array:- data store simultenously in a similar datatype.



 Posted by: fakir naik    

Contact fakir naik  Contact fakir naik

ARRAY IS THE COLLECTION OF SIMLER TYPE OF DATA ITEN <br>POINTER IS A VARIBALE WICH HOLD THE ADDRES OF ANOTHER VARIBALE



 Posted by: faiz misbah    

Contact faiz misbah  Contact faiz misbah

Pointer: Pointer is the variable that stores the address of the another variable..<br>Array: Array is used to store the number of values under a same name..



 Posted by: Anand T.M    

Contact Anand T.M  Contact Anand T.M

Arrays: Fixed size length ( compile time)<br>Pointers: Variable size ( run time)



 Posted by: prakash    

Contact prakash  Contact prakash

ARRAY:array works as a contaner that contains the variable of same type.<br><br>POINTERT:It also work as a container that contains the address of another variable.



 Posted by: Rjbalu    

Contact Rjbalu  Contact Rjbalu

Pointer is used to hold the adress of another variable.Through this address we con print the value of the variable whose address is taken by Pointer through pointer variable.
While array is used to store the values of same data type in index form starting from zero because compiler consider it as positive integer



 Posted by: majid nawaz    

Contact majid nawaz  Contact majid nawaz

array:is collection of similar datatypes.
pointer:is a address memory varible.



 Posted by: lakshmi    

Contact lakshmi  Contact lakshmi

the difference between array and pointer is the array is collection of similar datatypes,pointer is a addres memory variable.



 Posted by: lakshmi    

Contact lakshmi  Contact lakshmi

pointers can be allocate the memory at run time i.e the size of the variable can be allocate at run time but arrays didnt done that.



 Posted by: sadhana    

Contact sadhana  Contact sadhana

Pointer: Pointer is a variable,which can be store an address of same datatype variable.

Array: Array is a collection of same datatype variables.It is taken the memory as sequential.



 Posted by: AAYUSH MITTAL    

Contact AAYUSH MITTAL  Contact AAYUSH MITTAL

Pointer or Array name, both store memory address of other location. Array name and Pointer vsrible names can be interchangably used for each other. Only difference is Ptr++ is a valid statement but arr++ is not. In other words, array name is compiler se pointer and can not be moved with arr++. While user declared pointer can be moved Ptr++.



 Posted by: Vijay Tank    

Contact Vijay Tank  Contact Vijay Tank

array's decompose into pointers..
An array is nothing but a implicit pointer.
int a[5]; the compiler converts this as int *const a; As the address can not be altered.
int b[3] , then a=b ; not posible, Mr Denise Ritche made it so there is no memory leak.



 Posted by: mahanth hiremath    

Contact mahanth hiremath  Contact mahanth hiremath

Pointer is a variable which holds the address of another variable where as An ARRAY is a set of similar data items stored simultaneously.



 Posted by: S.Ramesh    

Contact S.Ramesh  Contact S.Ramesh

Pointer is use to access the data with its address. and array is the collection of similar data for access and manipulate.



 Posted by: deepak chaudhary    

Contact deepak chaudhary  Contact deepak chaudhary

array is collection of hemogenius datatypes but pointer is a memory variable used to access the address of the another variable.through pointer we can access the values of the variale.
declaration of an array:
datatype variablename[size];
pointer declaration:
datatype *pointer variable name;
*-represents the dereferencing operator



 Posted by: k.ganeshwari    

Contact k.ganeshwari  Contact k.ganeshwari

pointer is used to address of the memory location.syntax:datatype *pointer variable;
array is a homogenous datatype.syntax:datatype variable<row size><column size>



 Posted by: remeena.v    

Contact remeena.v  Contact remeena.v


If you have the better answer, then send it to us. We will display your answer after the approval.
Name :*
Email Id :*
Answer :*
Verification Code Code Image - Please contact webmaster if you have problems seeing this image code Not readable? Load New Code
Process Verification  Enter the above shown code:*
Inform me about updated answers to this question

   
Related Questions
View Answer

Please Note: We keep on updating better answers to this site. Subscribe to our newsletter to get notified when better answer is posted.

Notify me when better answer is posted!
Email:

View ALL C Interview Questions

User Options
Sponsored Links


Copyright ©2003-2010 CoolInterview.com, All Rights Reserved.
Privacy Policy | Terms and Conditions
Page URL: http://www.coolinterview.com/interview/960/default.asp?cachecommand=bypass


Download Yahoo Messenger | Placement Papers| FREE SMS | ASP .Net Tutorial | Web Hosting | Free SMS | Dedicated Servers | Joke of the Day

1.03