Write a program in C to demonstrate the use of & (address of) and *(value at address) operator

Previous
Next

Solution:

  • Address operator is used to returns the memory location of specified variable.
  • Pointer operator is used to returns the data which is present in the specified memory location.
  • The following example describes the use of address and pointer variables.
#include<stdio.h>
void main()
{
	int i=100;
	int* ptr ;
	ptr = &i;
	printf("%d\n",i);
	printf("%u\n",ptr);
	printf("%u\n",&i);
	printf("%u\n",&ptr);
	printf("%d\n",*ptr);
	printf("%d\n",*(&i));
	printf("%d\n",*(*(&ptr)));
}
Previous
Next

Courses Enquiry Form