Question: Hello, I am unable to code any of this program besides simply the skeleton code for how it should run as I have not learned
Hello, I am unable to code any of this program besides simply the skeleton code for how it should run as I have not learned this topic yet.
For each of the following, please write C++ statements that perform the specified task.
Declare an array of type unsigned int called values with five elements, and initialize the elements to the even integers from 2 to 10. Assume that the symbolic constant SIZE has been defined as 5.
#define SIZE 5
unsigned int values[SIZE] = {2,4,6,8,10};
Declare a pointer vPtr that points to an object of type unsigned int.
int *vPtr;
Use a for statement to print the elements of array values using array subscript notation.
Use a for statement to print the elements of array values using pointer / offset notation.
Use a for statement to print the elements of array values using pointer / offset notation with the array name as the pointer.
Use a for statement to print the elements of array values by subscripting the pointer vPtr.
Use the address-of operator & to display the addresses of all elements in the array.
Thank you ahead of time for your help.
Here is the skeleton code for the program:
#include
#include
#define SIZE 5
using namespace std;
int main()
{
int values[SIZE] = {2,4,6,8,10};
int *vPtr = values;
//Question 1.
cout << " Question 1 output ";
cout << "Array Subscript Notation" << endl;
for ( int i = 0; i < SIZE ; i++ )
{
cout << "values[" << i << "] = "<< values[ i ] << endl;
}
//Question 2.
cout << " Question 2 output ";
cout << "Pointer / offset notation." << endl;
// Add code here
//Question 3
cout << " Question 3 output ";
cout << "Pointer/offset notation where the pointer is the array name ";
// Add code here
//Question 4
cout << " Question 4 output ";
cout << " Pointer subscript notation ";
// Add code here
//Question 5
cout << " Question 5 output ";
cout << " Address-of operator ";
// Add code here
return 0;
}
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
