Logo 
Search:

C Programming Articles

Submit Article
Home » Articles » C Programming » BeginnersRSS Feeds

Program to print the address of a variable along with its value

Posted By: Tilly Hughes     Category: C Programming     Views: 7723

Write a program to print the address of a variable along with its value.

Code for Program to print the address of a variable along with its value in C Programming

   main()                                                           
   {
       char   a;                                                    
       int    x;                                                    
       float  p, q;                                                 
                                                                    
       a  = 'A';                                                    
       x  = 125;                                                    
       p  = 10.25, q = 18.76;                                       
       printf("%c is stored at addr %u.\n", a, &a);                 
       printf("%d is stored at addr %u.\n", x, &x);                 
       printf("%f is stored at addr %u.\n", p, &p);                
       printf("%f is stored at addr %u.\n", q, &q);                 
                                                                    
   }                                                                
                                                                    
Output                                                           
                                                                    
   A is stored at addr 4436.                                        
   125 is stored at addr 4434.                                      
   10.250000 is stored at addr 4442.                                
   18.760000 is stored at addr 4438.
  
Share: 



Tilly Hughes
Tilly Hughes author of Program to print the address of a variable along with its value is from London, United Kingdom.
 
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!