Answer to Question #321121 in C for Trusting

Question #321121

Write a program in C to show the basic declaration of pointer. 


Pointer : Show the basic declaration of pointer :                                                            
-------------------------------------------------------                                                       
 Here is m=10, n and o are two integer variable and *z is an integer                                          
                                                                                                              
 z stores the address of m  = 0x7ffd40630d44                                                                  
                                                                                                              
 *z stores the value of m = 10                                                                                
                                                                                                              
 &m is the address of m = 0x7ffd40630d44                                                                      
                                                                                                              
 &n stores the address of n = 0x7ffd40630d48                                                                  
                                                                                                              
 &o  stores the address of o = 0x7ffd40630d4c                                                                 
                                                                                                              
 &z stores the address of z = 0x7ffd40630d50      





1
Expert's answer
2022-03-30T14:09:55-0400
#include <stdio.h>

int main() {
    int m=10, n, o;
    int *z;

    printf("Pointer : Show the basic declaration of pointer :\n");
    printf("-------------------------------------------------------\n");
    printf("Here is m=%d, n and o are two integer variable and *z is an integer\n", m);

    z = &m;               
    printf("z stores the address of m  = 0x%p\n", z);                                                                                                            
    printf("*z stores the value of m = %d\n", *z);                                                                                                             
    printf("&m is the address of m = 0x%p\n", &m);                                                                                                             
    printf("&n stores the address of n = 0x%p\n", &n);                                                                                                             
    printf("&o stores the address of o = 0x%p\n", &o);                                                                                                             
    printf("&z stores the address of z = 0x%p\n", &z);

    return 0;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS