Sunday 9 March 2014

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

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.

No comments:

Post a Comment