Header Ads Widget

How to access the value of some variable using pointer

 In this article we will learn how to access the value of  any variable by using pointer . lets there is a variable and a pointer PFor access the value of  x by using pointer P we have to Asterisk ( * ) operator. 



#include<stdio.h>
int main()
{
int x=10;
// pointer declaration
int *p;
// pointer initialization
p=&x;
printf("Value of X is %d\n",x);
printf("Address of the x is %u\n",&x);
printf("Address of X or Value of pointer P is %u\n",p);
printf("Value of X using pointer P %d\n",*p);
printf("Address of P is %u\n",&p);
return 0;
}

Output:-

Value of X is 10
Address of the x is 3315116764
Address of X or Value of pointer P is 3315116764
Value of X using pointer P 10
Address of P is 3315116768




👉Structure in C-Next>>

Recommended Post:

Key points:-

Cracking the coding interview:-

 Array and string:-

Tree and graph:-

Hackerearth Problems:-

Hackerrank Problems:-

Data structure:-

 MCQs:-



Post a Comment

0 Comments