CoolInterview.com - World's Largest Collection of Interview Questions
Interview Success Kit - 9,000 Interview Que. & Ans.
Covers 9,000+ Interview Questions asked in actual MNC Interviews - all with model answers.
Start Your Own website Now
Sponsored Links

Interview Questions
Our Services


INTERVIEW QUESTIONS C POINTERS IN C DETAILS
Question :
Difference between arrays and pointers?
Category Pointers in C Interview Questions
Rating (0.3) By 187 users
Added on 10/22/2004
Views 27418
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.<br>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.<br>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.<br><br>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..<br>An array is nothing but a implicit pointer.<br> int a[5]; the compiler converts this as int *const a; As the address can not be altered.<br>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.<br>declaration of an array:<br>datatype variablename[size];<br>pointer declaration:<br>datatype *pointer variable name;<br>*-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;<br>array is a homogenous datatype.syntax:datatype variable<row size><column size>



Posted by: remeena.v    

Contact remeena.v Contact remeena.v

pointers are used to poinnt to th eaddress of another variable.but in array we can store more elements using same array name.<br>for eg:student[10].int this u can store 10 students using one array name student.



Posted by: vijayalakshmi    

Contact vijayalakshmi Contact vijayalakshmi

Pointers are basically address variables...which can be assigned memory dynamically through malloc and calloc to store any data....while array is a statically allocated memory space in a contigeous format of group of identical data-members..



Posted by: Pinki Ruparel    

Contact Pinki Ruparel Contact Pinki Ruparel

POINTERS:<br> *POINTER IS THE VARIABLE IT HOLDS THE ADDRESS OF ANOTHER VARIABLE<br> *ARRAY HAVING THE COLLECTION OF SIMILAR DATA TYPE.<br> *WE DIDN'T PASS THE ARRAY AS ARGUMENT.<br> * BUT WE CAN PASS THE POINTER AS ARGUMENT.



Posted by: anjana priyadharshini    

Contact anjana priyadharshini Contact anjana priyadharshini

array is an implicit pointer.which stores the address of first value in the array.this follows contiguous memory allocation. where as pointer also stores the address of the another variable.nested pointers also exist.



Posted by: rani    

Contact rani Contact rani

array is continuous allocation of similar data types...you cannot change allocation address in an array<br>where a *(pointer) stands for value at address.<br>int *a means value at the address a is of type integer.



Posted by: matang    

Contact matang Contact matang

array:array is a collection of same data type.<br>pointer:it can store an address of same data type variable



Posted by: revathi    

Contact revathi Contact revathi

POINTER IS A VARIABLE WHICH CONATAINS THE ADDRESS OF ANOTHER VARIABLE. ARRAY IS COLLECTION OF SIMILAR DATA TYPES AND INDEX START WITH 0 ONLY



Posted by: SRINIVAS    

Contact SRINIVAS Contact SRINIVAS

pointer is a variable that holds the address of another variable. array is a coolection of elements



Posted by: pooja    

Contact pooja Contact pooja

ARRAY:-<br>Array is the collection of similar type of data.It's syntax is<br> data type varibl name[];<br>POINTER:-<br>It's holds the address of another variable.It's syntax is<br> *p.<br>



Posted by: kishor    

Contact kishor Contact kishor

basically pointer is used to create dynamically memory allocation so its really help from wetage of memory.where as array is fixed size of memory allocation so it may some time waste memory so this is major differece between array & pointer



Posted by: ronak mistry    

Contact ronak mistry Contact ronak mistry

Arrays are just the collection of similar items and pointers are the address to the functions



Posted by: venkat ANR College    

Contact venkat ANR College Contact venkat ANR College

Pointer is an variable which stores the address of another variable<br>An array is a collection of similar data types it stores in contiguios memory location...



Posted by: ankur chourasia    

Contact ankur chourasia Contact ankur chourasia

pointers is an adress in memory where the varible is located.<br>Arrays is stored conitnuos memory allocation and used subscripted variables.



Posted by: swathisrikar    

Contact swathisrikar Contact swathisrikar

array is a collection of similar data types. pointer is a container contains the address of another variable. the concept is different allocating memory.



Posted by: vishal    

Contact vishal Contact vishal

(1)pointer can be increment and decrement but the array can not be incremeted and decremented.<br>(2)array can not be pass by value whenever the array are always pass by referance



Posted by: kamal thakur    

Contact kamal thakur Contact kamal thakur

The most important thing is that, even compiler compiler manipulate arrays in pointer forms only. Array is a constant pointer and address can't be chnaged once declared, while pointer can be re-assigned any number of times. Arrays are easy to use and manipulate, while pointers are tough to use if you are familiar with them. Array doesn't take any additional memory space while pointer takes. Post/pre increment/decrement is possible for pointer while not in arrays.



Posted by: Devendra Bhadoriya    

Contact Devendra Bhadoriya Contact Devendra Bhadoriya

Pointers are variables stored in non-linear manner whereas array is a data structure in which elements are stored in linear manner.



Posted by: vipul arora    

Contact vipul arora Contact vipul arora

1.array is a collection of similar data type.<br>2.Array has fixed size.<br>3. Pointer holds the address of any type variable.<br>we can point an array by ponier variable



Posted by: Gowri    

Contact Gowri Contact Gowri

Pointers are used to manipulate data by using address or they are address variable used to store address.Pointers use * operator to access data.1)pointer can be increment and decrement but the array can not be incremeted and decremented.Pointers are variables stored in non-linear manner whereas array is a data structure in which elements are stored in linear manner.



Posted by: Md. Sajid khan    

Contact Md. Sajid khan Contact Md. Sajid khan

If you have the better answer, then send it to us. We will display your answer after the approval.
Rules to Post Answers in CoolInterview.com:-

  • There should not be any Spelling Mistakes.
  • There should not be any Gramatical Errors.
  • Answers must not contain any bad words.
  • Answers should not be the repeat of same answer, already approved.
  • Answer should be complete in itself.
  • 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. In case you are looking for Jobs, Pls Click Here Vyoms.com - Best Freshers & Experienced Jobs Website.

    View ALL Pointers in C Interview Questions

    User Options
    Sponsored Links


    Copyright ©2003-2016 CoolInterview.com, All Rights Reserved.
    Privacy Policy | Terms and Conditions

    Download Yahoo Messenger | Placement Papers| FREE SMS | ASP .Net Tutorial | Web Hosting | Dedicated Servers | C Interview Questions & Answers

    Testing Articles | Testing Books | Testing Certifications | Testing FAQs | Testing Downloads | Testing Interview Questions | Testing Jobs | Testing Training Institutes


    Cache = 0.016113 Seconds