Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Problem 1 (Multiple Choice, 4 pts each) Fo r the problems below, choose the BEST

ID: 3753390 • Letter: P

Question

Problem 1 (Multiple Choice, 4 pts each) Fo r the problems below, choose the BEST answer from the list of CICLE the letter for your answer 1. The proper way to declare a variable my var p of type pointer to float is: a float my var p b. rLoat my var pi o float &my var p 2. Suppose the following code to declare a variable called ptr appears in the program. What could be assigned to ptr and the code would compile without errors? char a a. 12 b &S Welcome cs305" d. both (a) and (b) e. both (b) and (c) f none of the above 3. Suppose the following code is compiled and executed. All appropriate headers are included and the code is written in the main function. What is printed? double dDigit 3.14 double p dDigit - &dDigit: printf("size of dDigit: %d ", sizeof (dDigit)); printf("size of p-dDigit: %d " , sizeof (p-dDigit)); a. size of dDigit: 4 b. size of dDigit: c. size of dDigit: 8 d. size of dDigit: 8 size of p dDigit: 4 size of p dDigit: 8 size of p_dDigit:4 size of p_dDigit: 8

Explanation / Answer

1. The answer will be "a". You have to declare a pointer of a float, so it should be float *.

So, it will be float *my_var_p;

2. The answer willbe "b". "ptr" is a pointer to a char type. So, it should take the address of an char. Since here "char a" is already defined, so ptr will take the address of "char a". The answer will be "char *ptr = &a;"

3. Assume you are running this in 32 bit machine. Then the answer will be "c". The size of a double variable will be 8 byte. Now the pointer size will be 4 byte for 32 machine (it will not dependent on whether it's a pointer to double / pointer to int / pointer char). If you run this same piece of code in 64 bit machine then the answer will be "d", since for 64 bit machine the pointer size is 8 byte.

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote