Question

In: Computer Science

THE FOLLOWING MUST BE CODED IN C THE FOLLOWING MUST BE CODED IN C THE FOLLOWING...

THE FOLLOWING MUST BE CODED IN C THE FOLLOWING MUST BE CODED IN C

THE FOLLOWING MUST BE CODED IN C   THE FOLLOWING MUST BE CODED IN C

Write a program that demonstrates handling pointers. Create two integer variables m and n, and two pointers, pm pointing to m, and pn pointing to n.

Produce the following output:

Address of m: 0x7ffcc3ad291c

Value of m: 29

Address of n: 0x7ffcc3ad291d

Value of n: 34

Now pm is pointed to m by assigning the address of m to pm

Address of pointer pm: 0x7ffcc3ad2100

Value of pointer pm: 0x7ffcc3ad291c

Content of pointer pm (dereferencing): 29

Now pn is pointed to n by assigning the address of n to pn

Address of pointer pn: 0x7ffcc3ad2101

Value of pointer pn: 0x7ffcc3ad291d

Content of pointer pn (dereferencing): 34

Thank you!

Solutions

Expert Solution

#include <stdio.h>
int main()
{
int m=29,n=34;
int* pm, *pn;
  
  

printf("Address of m: %p\n", &m);
printf("Value of m: %d\n", m);
printf("Address of n: %p\n", &n);
printf("Value of n: %d\n", n);

pm=&m;
pn=&n;

printf("Address of pointer pm: %p\n", &pm);
printf("Value of pointer pm: %p\n", pm);
printf("Content of pointer pm(dereferencing): %d\n",*pm);
  
printf("Address of pointer pn: %p\n", &pn);
printf("Value of pointer pn: %p\n", pn);
printf("Content of pointer pn(dereferencing): %d\n",*pn);
  

return 0;
}


Related Solutions

Must be coded in C#. 10.8 (Rational Numbers) Create a class called Rational for performing arithmetic...
Must be coded in C#. 10.8 (Rational Numbers) Create a class called Rational for performing arithmetic with fractions. Write an app to test your class. Use integer variables to represent the private instance variables of the class—the numerator and the denominator. Provide a constructor that enables an object of this class to be initialized when it’s declared. The constructor should store the fraction in reduced form. The fraction 2/4 is equivalent to 1/2 and would be stored in the object...
THE FOLLOWING IS CODED IN C Write a function that sets each element in an array...
THE FOLLOWING IS CODED IN C Write a function that sets each element in an array to the sum of the corresponding elements in two other arrays. That is, if array 1 has the values 2,4, 5, and 8 and array 2 has the values 1, 0, 4, and 6, the function assigns array 3 the values 3, 4, 9, and 14. The function should take three array names and an array size as arguments. Test the function in a...
The following is coded in C++. Please point out any changes or updates you make to...
The following is coded in C++. Please point out any changes or updates you make to the existing code with comments within the code. Start with the provided code for the class linkedListType. Be sure to implement search, insert, and delete in support of an unordered list (that code is also provided). Now, add a new function called insertLast that adds a new item to the END of the list, instead of to the beginning of the list. (Note: the...
The following is coded in C++. Please point out any changes or updates you make to...
The following is coded in C++. Please point out any changes or updates you make to the existing code with comments within the code. Start with the provided code for the class linkedListType. Be sure to implement search, insert, and delete in support of an unordered list (that code is also provided). Also, add a new function called insertLast that adds a new item to the END of the list, instead of to the beginning of the list. (Note: the...
The following is coded in C++. Please point out any changes or updates you make to...
The following is coded in C++. Please point out any changes or updates you make to the existing code with comments within the code. Start with the provided code for the class linkedListType. Be sure to implement search, insert, and delete in support of an unordered list (that code is also provided). Now, add a new function called insertLast that adds a new item to the END of the list, instead of to the beginning of the list. (Note: the...
this has to be coded in c ++ • Write a program which generates a DIFFERENT...
this has to be coded in c ++ • Write a program which generates a DIFFERENT random number between 1 and 100 everytime you run the program. Please go online and see how poeple are trying to solve this. You can submit their code. Make sure you include a comment which shows from where the code was taken. You do not need to understand the code but if you can, thats great. This program will be used in the upcoming...
**CODED IN C LANGUAGE** Case 1: The given snapshot in the assignment instructions checks for the...
**CODED IN C LANGUAGE** Case 1: The given snapshot in the assignment instructions checks for the following: P to be switched with Q (Once done will remain as it is in all the rows) If the user enters the same P again, the program must not make any changes For instance, given elements are 0123456789 3 4          0              0124456789 2 5          1              0154456789 (Keeping the change in Row 0 (input for row 1); 2 is switched to 5) 1 6          2              0654456789 (Keeping...
****NEED CODED IN C++, READ THE INSTRUCTIONS CAREFULLY AND PAY ATTENTION TO THE INPUT FILE, IT...
****NEED CODED IN C++, READ THE INSTRUCTIONS CAREFULLY AND PAY ATTENTION TO THE INPUT FILE, IT IS REQUIRED FOR USE IN THE PROBLEM**** You are to generate a list of customers to serve based on the customer’s priority, i.e. create a priority queue/list for a local company. The company has been receiving request and the request are recorded in a file, in the order the request was made. The company processes each user based on their priority, the highest priority...
Must be coded in python. Consuming A Web Service with Python Consuming data from programmable web...
Must be coded in python. Consuming A Web Service with Python Consuming data from programmable web based API’s is growing rapidly. According to ProgrammableWeb, in just six years (2010-2016), web API counts increased 758 percent with the majority being REST based. This is driven by a myriad of factors but growth of cloud based applications, (distributed computing by another name), and the resulting need to integrate the different categories is a major factor. Description Write a client to consume a...
How is this method coded in Java?
How is this method coded in Java?
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT