Tag Archives: pointer

A good example of pointer code at Hacker Rank

A good example of pointer code at Hacker Rank:

 

Pointer

What is pointer?
Pointer is actually a variable which points to another variable by address not value

notation is simple just a asterisk before the variable name

Example:

suppose
int live=20;
int *zaki=&live; //here i am pointing *zaki to a variable address of live
so *zaki is a pointer

now we want to print what actually shows

if we write these line
printf(“zaki = %d”,*zaki);

Output will be: 20 //the value of live

And if we print
printf(“zaki = %d”,zaki);
Output will be: 2686744 //the address of memory location of  the variable live