C program to print address of integer using pointer

Simple C program to print address of integer using pointer: We know that pointer stores the address of another variables. To print address of integer, we declare a pointer to integer variable and store the address of integer into it. To print address, we use %u.
 
/* C Program to print address of integer */
#include<stdio.h>
int main()
{
 int n,*p;
 printf("Enter a integer: ");
 scanf("%d",&n);
 /* Sotre address of n into p */
 p=&n;
 printf("Address = %u",p);
 return 0;
}
/* End of the program */
 

Another C program to print address of integer
 
/* C Program to print address of integer */
#include<stdio.h>
int main()
{
 int n,*p;
 printf("Enter a integer: ");
 scanf("%d",&n);
 /* Sotre address of n into p */
 p=&n;
 printf("Address = %u\n",&n);
 printf("Address = %u",p);
 return 0;
}
/* End of the program */


Popular posts from this blog