Logo 
Search:

C Programming Articles

Submit Article
Home » Articles » C Programming » Homework HelpRSS Feeds

Program to print address of a variable using & and * operators

Posted By: Vilmos Fischer     Category: C Programming     Views: 2044

Write a program to print address of a variable using & and * operators.

Code for Program to print address of a variable using & and * operators in C Programming

#include<stdio.h>
#include<conio.h>

void main()
{
    int x,y;
    int *ptr;
    clrscr();

    x = 10;
    ptr = &x;
    y = *ptr;

    printf("Value of x is %d \n\n",x);
    printf("%d is stored at addr %u\n",x,&x);
    printf("%d is stored at addr %u\n",*&x,&x);
    printf("%d is stored at addr %u\n",*ptr,ptr);
    printf("%d is stored at addr %u\n",y,&*ptr);
    printf("%d is stored at addr %u\n",ptr,&ptr);
    printf("%d is stored at addr %u\n",y,&y);

    *ptr = 25;
    printf("\nNow x = %d\n",x);
    getch();
}
  
Share: 



Vilmos Fischer
Vilmos Fischer author of Program to print address of a variable using & and * operators is from Frankfurt, Germany.
 
View All Articles

Related Articles and Code:


 
Please enter your Comment

  • Comment should be atleast 30 Characters.
  • Please put code inside [Code] your code [/Code].

 
No Comment Found, Be the First to post comment!