Answer to Question #273308 in C for Mr Z

Question #273308

9) Enter the code

#include <stdio.h>

int main(int argc, char *argv[]) 
{
    
    int a;
    int *b;
    
    b = &a;  // b contains the address of a

    // Display the value of b and the dereferenced value
    printf("b = %d, *b = %d\n", b, *b); 

    // Assign a value to a
    a = 3245;

    // Display the value of b and the dereferenced value
    printf("b = %d, *b = %d\n", b, *b); 
    
    return 0;
}


• Make the following two-line addition to the end of the code

Assign the value 12345 to the dereferenced pointer b. In other words, assign the value 12345 to *b

Display the value of a.

Write a short reflective account explaining the functionality of your modifications.


1
Expert's answer
2021-11-30T18:19:18-0500
#include <stdio.h>

int main(int argc, char *argv[]) 
{
    
    int a = 12345;
    int *b;
    
    b = &a;  // b contains the address of a

    // Display the value of b and the dereferenced value
    printf("b = %d, *b = %d\n", b, *b); 

    // Assign a value to a
    a = 3245;

    // Display the value of b and the dereferenced value
    printf("b = %d, *b = %d\n", b, *b); 
    
    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