Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Please be in programming language C. Thanks! Write a C program to work on pointers. In main ) you will first .Declare five integer variables
Please be in programming language C. Thanks!
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 a, b, c, as 10, 20, 30, respectively .Declare three integer pointers named as pa, pb, pc. These pointers should initially hold the addresses of variables a, b, c, respectively Declare three inte pointers should initially hold the addresses of pointers pa, pb, . These pointers to pc, respectively ger pointers to pointers as ppa, ppb, ppc .If needed for the below tasks, you can declare other variables as well as pointers later Now implement the following tasks in the main (O Write the necessary statements to print the values of a, b, c by just using a, pb, ppc Write the necessary statements to find the sum of the values in a, b, c by just using a, pb, 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 a and b Write the necessary statements to exchange the values/addresses in pa and pb by just using pa, ppb and maybe a temp pointer that you can declare. Then print the values of a and b by directly using a and b as wells as indirectly by using *pa and *pb. Explain what happens here, why the values of a and b did not change when we access them directly while it seems they changed when we access them indirectly. Type your explanation as a C comment in your program after the printf statements. o (direct, indirect, indirect indirect access) o o o Now copy/paste the following functions before your main() void increaseA (int val val++; void increaseB (int *pval) pval++; void increaseC (int *pval) pval++: void increaseD (int pval) (*pval)+ . Then call each of these functions in main) as follows increaseA (a) increaseB (&a); increaseC (&a); increaseD (&a) and print the value of a after each call to see what happens. Accordingly, explain why the first three call did not cause any change on variable a while the last one increases it by 1. Type your explanation as a C comment next to the above calls in your programStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started