C ONLY ANSWER AS MANY AS YOU CAN MAKE SURE THEY ARE RIGHT AL

C++ ONLY!!!! ANSWER AS MANY AS YOU CAN. MAKE SURE THEY ARE RIGHT!!!! ALSO LABEL WHAT QUESTION THE ANSWER IS TO!! ANSWER AS MANY AS POSSIBLE!!! THANKS MUCH

1. Declare an array named AR to hold 4 integers and fill it with the numbers 2, 4, 6, and 8.

2. Assume an array called AR contains 4 integers. Write a loop to print out the values of the 4 integers.

3. Assume an array called AR contains 4 integers. Write code to exchange the very first and the very last values in the array.

4. Declare an array named AR to hold 1000 integers. In the declaration statement, initialize the array so the very first value is 10, the second is 20, and all the rest are 0.

5. Complete the following sentence: If you declare an array to hold N values, legal subscripts run from _____ to ______.

6. Complete the following sentence: the unsubscripted name of an array is _______________________________.

7. Write code to swap element [2] and element [4] in an array of floats called AR. Declare a simple variable called temp for this question, and assume the array is correctly declared and initialized.

8. Write code to copy the 0th element of an array called AR into all the other elements of the array. Assume there are 10 elements in the array.

9. Complete the following sentence: all the elements of an array must be the same ____________.

10. (True/False) ALL of the declared elements in an array MUST be initialized and used.

Solution

1. Declare an array named AR to hold 4 integers and fill it with the numbers 2, 4, 6, and 8.
int AR[4];
for(int i = 0; i < 4; i++)
AR[i] = 2 * (i+1);

2. Assume an array called AR contains 4 integers. Write a loop to print out the values of the 4 integers.
for(int i = 0; i < 4; i++)
cout<<AR[i]<<\" \";
cout<<endl;

3. Assume an array called AR contains 4 integers. Write code to exchange the very first and the very last values in the array.
int temp = AR[0];
AR[0] = AR[3];
AR[3] = temp;

4. Declare an array named AR to hold 1000 integers. In the declaration statement, initialize the array so the very first value is 10, the second is 20, and all the rest are 0.
int AR[1000] = {10, 20};
5. Complete the following sentence: If you declare an array to hold N values, legal subscripts run from __0__ to __N-1__.
6. Complete the following sentence: the unsubscripted name of an array is __pointer to the array__.
7. Write code to swap element [2] and element [4] in an array of floats called AR. Declare a simple variable called temp for this question, and assume the array is correctly declared and initialized.
float temp = AR[2];
AR[2] = AR[4];
AR[4] = AR[2];
8. Write code to copy the 0th element of an array called AR into all the other elements of the array. Assume there are 10 elements in the array.
for(int i = 1; i < 10; i++)
AR[i] = AR[0];
9. Complete the following sentence: all the elements of an array must be the same __data type__.
10. (True/False) ALL of the declared elements in an array MUST be initialized and used. False.

C++ ONLY!!!! ANSWER AS MANY AS YOU CAN. MAKE SURE THEY ARE RIGHT!!!! ALSO LABEL WHAT QUESTION THE ANSWER IS TO!! ANSWER AS MANY AS POSSIBLE!!! THANKS MUCH 1. De

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site