#include <stdio.h>
int main(void) {
//pointer variable of type int
int *ptr = NULL;
printf("Value stored in ptr: %ld\n", ptr);
return 0;
}
Value stored in ptr: 0
Initialize pointer variables with addresses
#include <stdio.h>
int main(void) {
//num variable
int num = 10;
//pointer variable
int *ptr;
//assign address of num variable to ptr pointer variable
ptr = #
//print the value stored in num using the num variable
printf("Value stored in num: %d\n", num);
//print address of num stored in ptr variable
printf("Address of num variable: %ld\n", ptr);
//print address of ptr variable
printf("Address of ptr variable: %ld\n", &ptr);
//print the value stored in num using ptr variable
printf("Value stored in num using ptr variable: %d\n", *ptr);
return 0;
}
Value stored in num: 10 Address of num variable: 140732844468280 Address of ptr variable: 140732844468272 Value stored in num using ptr variable: 10