Answered step by step
Verified Expert Solution
Question
1 Approved Answer
University of Windsor COMP 1410 - Winter 2020 School of Computer Science Lab 05 - Working with Pointer (Due Date: Feb 28, 2020) Purpose The
University of Windsor COMP 1410 - Winter 2020 School of Computer Science Lab 05 - Working with Pointer (Due Date: Feb 28, 2020) Purpose The purpose of this lab is to help you to practice working with pointers and basic operations using pointers. Learning Outcomes Understand what is a variable pointer and what do we mean by pointers only store address Understand how call by value and call by reference (pointer) works? Why pointers need to have an explicit data type when we declare them. Part 1.1: Test and Observe #include int main() int a = 7; int *aPtr; aPtr = &a; // This statement will print the value of a printf("stat 01: %d ", a); // This statement will print printf("stat 02: Xp ", &a); // This statement will print .... printf("stat 03: Xp ", aptr); // This statement will print .. printf("stat 84: Xp ", &aptr); // This statement will print printf("stat 05: Xd ", a); // This statement will print printf("stat 06: Xd In", aptr); // This statement will print ... printf("stat 07: Xp ", *&aPtr); // This statement will print .... printf("stat 88: Xp ", &*aptr); // This statement will print .. printf("stat 09: %d ", *&a); return; University of Windsor COMP 1410 - Winter 2020 School of Computer Science Q1) - Read the above code carefully and try to guess what each print statement is going to print when you execute the code. Write down your guessing by completing the code comments Q2). Run the code and compare your guessing with the actual output and change your code comments if needed Part 1.2: Test and Observe int main() { float b = 3.7f; float .bptr; // This statement will print ... printf("stat 01: value of b = X ", b); // This statement will print the unsigned int presentation of the address // that bPtr pointing at in memory printf("stat 02: Xu ", bptr); // let bPtr point to the address of variable b in memory bPtr = 8b; // Write down the value you will get from this print statement, call it vari printf("stat 63: Xu ", bptr); // this statement will print .... printf("stat 04: Xu ", 8b); printf("stat 05: currently bPtr store the address of variable b which is Xu in unsigned int format or Xp in hexadecimal format ", betr, bptr); // this statement will print ......... printf("stat 06: the size of b in memory is: Xd ", sizeof(b)); // this statement is going to ......... bPtr // Write down the value you will get from this print statement, call it var2 // write the value printf("stat 07: Xu ", bptr); return; Q1) - Read the above code carefully and try to guess what each print statement is going to print when you execute the code. Write down your guessing. Q2) - Run the code and compare your guessing with the actual output 93) - What is the difference between var2 and var1, in other words, va2-var1?? Could you explain it? University of Windsor COMP 1410 - Winter 2020 School of Computer Science Part 2: Programming Problems Q2.1) The following code should implement a sort algorithm to sort an array of integer numbers of sizen in ascending order. Complete the implementation of the Sort and Swap functions void PrintArray(int size, int array []){ for(int i=e; i
Step 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