Write a single C statement for each of the following . Declare an integer called
ID: 3737509 • Letter: W
Question
Write a single C statement for each of the following .
Declare an integer called total, initialize it to 10
Declare a pointer to an int called ptr and set it to point to the above variable total
Set the value of the above variable total to 20 using pointer ptr
Print the memory address of total using total and the specifier %p
Print the memory address of total using ptr and the specifier %p
Define a new pointer qtr and let it point to total using ptr
Make qtr point to integer variable result (assume result has been declared)
Double the value of result using qtr
Explanation / Answer
// 1 int total = 10; // 2 int *ptr = &total; // 3 *ptr = 20; // 4 printf("%p ", &total); // 5 printf("%p ", &ptr); // 6 int *qtr = ptr; // 7 qtr = &result; // 8 *qtr = (*qtr) * 2;
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.