Answered step by step
Verified Expert Solution
Question
1 Approved Answer
3. Answer each of the following. Assume that single-precision floating-point numbers are stored in 16 bytes, and that the starting address of the array is
3. Answer each of the following. Assume that single-precision floating-point numbers are stored in 16 bytes, and that the starting address of the array is at location 2010500 in memory. Each part of the exercise should use the results of previous parts where appropriate.
- Define an array of type float called numbers with 5 elements, and initialize the elements to the values 0.11, 0.22, 0.33, ..., 0.55. Assume the symbolic constant SIZE has been defined as 5.5 //I have
numbers[0]=0.0; numbers[1]=1.1; numbers[2]=2.2; numbers[3]=3.3; numbers[4]=4.4; numbers[5]=5.5;
- Define a pointer, nPtr, that points to an object of type float. //I have float *nPtr; nPtr = &numbers[0];
- Print the elements of array numbers using array subscript notation. Use a for statement and assume the integer control variable i has been defined. Print each number with 2 position of precision to the right of the decimal point.
- Give two separate statements that assign the address of last element of array numbers to the pointer variable nPtr. // I have int i; printf("Array elements are : ");
- Print the elements of array numbers using pointer/offset notation with the pointer nPtr. // I have printf(" "); for(i = 0; i < SIZE; i++), printf("%.1f ",*(nPtr+i));
- Refer to element 2 of array numbers using array subscript notation, pointer/offset notation with the array name as the pointer, pointer subscript notation with nPtr and pointer/offset notation with nPtr.
- Assuming that nPtr points to the end of array numbers, what address is referenced by nPtr - 5? What value is stored at that location?
- Assuming that nPtr points to numbers[5], what address is referenced by nPtr = 2? Whats the value stored at that location?
The other question I have is this:
-
- Write the function header for a function called myswap that takes two pointers to integer numbers x and y as parameters and returns a Boolean value.
- b) Write the function prototype for the function in part (a).
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