Questions about C language 2. (48 pts) Write a single C statement for each of th
ID: 3737414 • Letter: Q
Question
Questions about C language
2. (48 pts) 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 (see class notes) 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 3. (18 pts) Write a single statement to do each of the following Assign character 'Z' to the variable pointed to by char pointer answer Change the value of variable pointed to by char pointer choice to the next character Print the value of char pointer called answerExplanation / Answer
ANSWER 1: int total =10;
ANSWER 2: int *ptr=&total;
ANSWER 3: *ptr=20;
ANSWER 4: printf("%p",total);
ANSWER 5: printf("%p",*ptr);
ANSWER 6: int **qtr=&ptr;
ANSWER 7: qtr=&result;
ANSWER 8: 2(*qtr);
ANSWER 9: char var='Z'; char*answer=&var;
ANSWER 10: char*choice=answer;
ANSWER 11: printf("%d", *answer);
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.