Create a program that practices pointers Solved

20.00 $ 10.00 $

Goals 1. Create a program that practices pointers

Tasks

1. Define two variables, one integer and one floating point

2. Define two pointers, one pointing to the integer variable you created in step 1, and one pointing to the floating point variable you created in step 1

3. Define an integer array with room for 5 integers

4. Ask the user to enter an integer, and store it in the integer variable

5. Ask the user to enter a float, and store it in the floating point variable

6. Ask the user to enter 5 more integers, and store them in the array

7. Print out the address and contents of the integer and floating point variables (use the “0x%x” technique for addresses)

8. Print out the address and contents of the pointer variables – i.e., print the address of the pointer itself, the address stored in the pointer (i.e. the “content” of the pointer), and the dereferenced value (see example below)

9. Print out the address of the first element of the array, and the value in the last element of the array Make sure that your code compiles and runs successfully; Submit your C code via Blackboard Some example runs of the program are shown in the table below.

Enter an integer: 5 Enter a floating point number: 3.5 Enter another integer: 2 Enter another integer: -4 Enter another integer: 12 Enter another integer: 27829 Enter another integer: 101 Address 13ab02658 contains 5 Address 13ab0265c contains 3.5 Address 13ab02660 contains 13ab02658, which contains 5 Address 13ab02664 contains 13ab0265c, which contains 3.5 Address 13ab02668 is the address of the first element of the array The last element in the array is 22

Category:

Description

Goals 1. Create a program that practices pointers

Tasks

1. Define two variables, one integer and one floating point

2. Define two pointers, one pointing to the integer variable you created in step 1, and one pointing to the floating point variable you created in step 1

3. Define an integer array with room for 5 integers

4. Ask the user to enter an integer, and store it in the integer variable

5. Ask the user to enter a float, and store it in the floating point variable

6. Ask the user to enter 5 more integers, and store them in the array

7. Print out the address and contents of the integer and floating point variables (use the “0x%x” technique for addresses)

8. Print out the address and contents of the pointer variables – i.e., print the address of the pointer itself, the address stored in the pointer (i.e. the “content” of the pointer), and the dereferenced value (see example below)

9. Print out the address of the first element of the array, and the value in the last element of the array Make sure that your code compiles and runs successfully; Submit your C code via Blackboard Some example runs of the program are shown in the table below.

Enter an integer: 5 Enter a floating point number: 3.5 Enter another integer: 2 Enter another integer: -4 Enter another integer: 12 Enter another integer: 27829 Enter another integer: 101 Address 13ab02658 contains 5 Address 13ab0265c contains 3.5 Address 13ab02660 contains 13ab02658, which contains 5 Address 13ab02664 contains 13ab0265c, which contains 3.5 Address 13ab02668 is the address of the first element of the array The last element in the array is 22