1. Write a C statement for each of the following. (4 pts) a. Declare an integer
ID: 3806512 • Letter: 1
Question
1. Write a C statement for each of the following. (4 pts) a. Declare an integer called total, initialize it to 10 b. Declare a pointer to an int called ptr and set it to point to total c. Set the value of total to 20 using ptr d. Print the memory address of total using total e. Print the memory address of total using ptr f. Create a new pointer qtr and let it point to total using ptr g. Make qtr point to integer result (assume already result declared) h. Double the value of result using qtr 2. Write a statement to: (1.5 pts) a. Assign character 'Z' to the variable pointed to by char pointer answer b. Change the value of variable pointed to by char pointer choice to next character c. Print the value of char pointer answer 3. Consider the following program with only the variable declarations shown. For each statement, specify if it is true or false. (2.5 pts) int xi void alpha (int a)( int b void beta() static int k; void gamma (int x) int main() int x, y, z; int y, zExplanation / Answer
1.
a. int total=10;
b. int *ptr=total;
c. *ptr=20;
total =*ptr;
d. printf("Address of total variable: %x ", &total);
e. printf("Address of total variable: %x ", ptr );
f.int *qtr;
qtr = ptr;
g.*qtr = result;
3.
a. true
b. false
c. true
d. false
e. false
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.