Pls explain....

int *iptr, num1;
num1=10;
iptr=&num1;

The above code how will executed? What is the value of iptr???
my opinion address of num1 is assigned to iptr. So Both variables are take same address. So 10 is also assigned to iptr...

This is correct or not... Pls explain...
int *iptr, num1;

iptr is a pointer to an integer type, num1 is an integer
(a pointer is a special type of variable that holds a memory address)

num1=10;

num1 is assigned a value of 10

iptr=&num1;

iptr is assigned a value of the memory address of num1

address of num1 is assigned to iptr


yes - iptr holds the address of num1

So Both variables are take same address


no - iptr has its own memory address. the value that iptr holds is the memory address of num1.

So 10 is also assigned to iptr


no - iptr holds the memory address of num1. if you dereference a pointer you can retrieve the value from the object the pointer points to. (so *iptr = 10)
Last edited on
thanks dude...
Topic archived. No new replies allowed.