Question: Write a C program to work on pointers. In main () you will first Declare five integer variables named as a, b, c, temp, sum

Write a C program to work on pointers. In main () you will first

  • Declare five integer variables named as a, b, c, temp, sum and set the initial values for , as , respectively.
  • Declare three integer pointers named as pa, pb, pc. These pointers should initially hold the addresses of variables , respectively.
  • Declare three integer pointers to pointers as ppa, ppb, ppc. These pointers to pointers should initially hold the addresses of pointers pa, pb, pc, respectively.
  • If needed for the below tasks, you can declare other variables as well as pointers later..
  • Now implement the following tasks in the main ()
  • Write the necessary statements to print the values of by just using a, pb, ppc (direct, indirect, indirect indirect access)
  • Write the necessary statements to find the sum of the values in a, b, c by just using , ppc, sum. Then print sum.
  • Write the necessary statements to exchange/print the values in a and b, by just using pa, ppb and maybe temp. Then print and .
  • Write the necessary statements to exchange the values/addresses in pa and pb by just using and maybe a temp pointer that you can declare. Then print the values of and by directly using and as wells as indirectly by using *pa and . Explain what happens here, why the values of and did not change when we access them directly while it seems the changed when we access them indirectly. Type your explanation as a C comment in your program after the printf statements.
  • Now copy/paste the following functions before your main ()

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!