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


INTERVIEW QUESTIONS LANGUAGES C DETAILS
Question :
What is pointers and its uses?

Posted by: babu on 11/23/2007

Contact babu  Contact babu
Category C Interview Questions
Rating (4.8) By 23 users
Added on 11/23/2007
Views 1781
Rate it!
Answers:

Pointer is a variable which holds the address of the another variable.
for ex:int *p;
here p is a pointer which holds the address of inter variable.
uses of pointers:
1.To access array elements
2.Pointers use in dynamic memory allocation linked linked lists,trees,graphs.
3.Passing data in & out of without coping .
4.Create and manage your own data types.



 Posted by: uppala mamatha    

Contact uppala mamatha  Contact uppala mamatha

Pointer is a variable that contain address which is a location of another variable in the memory.It reduces length and complexity of the program and pointer can access the variable outside the functions it has high execution speed.



 Posted by: asha    

Contact asha  Contact asha

1.Pointer is a variable which can hold the address of another variable.
2.It is used to store the address of another variable.



 Posted by: prateek saluja    

Contact prateek saluja  Contact prateek saluja

Pointers are variables which hold address of other variables.Pointers can be used to make a function return more than one value simultaneously.



 Posted by: swathigade    

Contact swathigade  Contact swathigade

Pointer is a variable which stores the address of another variable.



 Posted by: A.swetha    

Contact A.swetha  Contact A.swetha

Pointer is a variable which stores the address of another variable.



 Posted by: himanshu sharma    

Contact himanshu sharma  Contact himanshu sharma

Pointers are variables that store the memory address of other variables.

They are declared the same way like any other variable but they are prefixed by a " * " which is called a dereference operator.

By using the "*" we stating that the actual variable is a pointer.

The pointer's data type must match the data type of the variable it points to.

Once declared the pointer variable can be assigned using the " & " operator , which means "the address of ".

By using pointers we can get the memory address of the actual variable where to the pointers points to , or we can get the actual value what is stored at the variable memory address.

#include <stdio.h>

int main()

{
int x=2;y=5;

int *xptr=&x;
int *yptr=&y;

printf("Address of x: 0x%p
",xptr);
printf("Address of y: 0x%p
",yptr);

return 0;

}

what you got?

The actual memory address of x and y variables!

by modifying the above example put the the" * " operators in the printf() functions before xptr and yptr we can get the values of x and y variables.






 Posted by: Andrew Gecse    

Contact Andrew Gecse  Contact Andrew Gecse

The following program illustrates a simple illustration of the use of a pointer:

#include <stdio.h>
int main(void) {
int count, *p;
count = 22;
p = &count;
printf("count is %d ", count);
printf("p is %ld ", p);
printf("*p is %d ", *p);
return 0;
}

Here, we create an integer count, and declare an int pointer p, declared as int *p. The command p = &count uses the address operator to associate the pointer p to the variable count. The results of running this program is

count is 22
p is 1245048
*p is 22

(the second line may differ on another machine, or at a different time). The important point for now is that p is some (perhaps mysterious) integer, whereas *p (being 22, the same as count) is the value of the pointer.

In a simplified way, one can think of pointers in the following way. When one declares a variable, your program asks the system for memory to store it. This memory has two (distinct) properties - the value stored, and the location (address) of where the memory block is. Running the program on different machines, or at another time, will result in the same value being stored, but the address location of the memory block may change. In the above example, p = &count associates the pointer with the address in memory where count is stored, and *p is used to access the value of the contents of that memory.



 Posted by: Krishnakant Babar    

Contact Krishnakant Babar  Contact Krishnakant Babar

pointer is variable which store the address of an other variable



 Posted by: sravan    

Contact sravan  Contact sravan


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
What is the difference between structure and union?
View Answer
What is pointer?
View Answer
Can we use functions within a structure?
View Answer
void main()
{
float a= 0.7;
if (a < 0.7)
printf("c");
else
printf("c++");
}
Output of the above program is c. Why? Whereas the same program with 0.8 instead of 0.7 gives c++ as the output? Why explain?
View Answer
Code for swapping of two numbers without using temporary variable using C.
View Answer
code To draw a three dimensional graph using c graphics
View Answer
How to write a C program for displaying a sentence without output command?
View Answer
What is difference between the test effort and the test procedure?
View Answer
What are the disadvantages of using Pointers.
View Answer
How can I convert a number to a string?
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/12512/default.asp?cachecommand=bypass


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

0.7