Question
using visual studio
2) For each of the following, write C++ statements that perform the specified task.. (Ref: classwork named pointer2) a) Decla
0 0
Add a comment Improve this question Transcribed image text
Answer #1

A) Here values is an array of size 5 which stored even numbers from 2 to 10 and each element is of type unsigned int

unsigned int values [5] = {2,4,6,8,10};

B) Here a is of type unsigned int and vptr is a pointer that points to a variable of typr unsigned int

unsigned int a;4
unsigned int * vptr = &a;

C)Following are the two ways of assigning start address of an array to the pointer variable

vptr = values;
vptr = &values[0];

D)Below loop is used to print the array elements using pointer subscript notation

for (int i=0;i<5;i++)
cout<<*(vptr+i);

E) here the index start from 0 so the first element is at index 0 hence the fifth element is at index 4 by vptr+4 we point to the fifth element and use derefrencing operator '*' to print its value

int fifth_value = *(vptr+4);

F)

start address = 1002500

ech element takes 2 bytes

then vptr+3 = 1002500+3*2

= 1002506

value stored at location is the third elemnt i.e. 8

Add a comment
Know the answer?
Add Answer to:
using visual studio 2) For each of the following, write C++ statements that perform the specified...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Using Microsoft Visual Studio. 1) Complete the following C++ program by adding more line of code...

    Using Microsoft Visual Studio. 1) Complete the following C++ program by adding more line of code for 8-bit signed array, 16-bit unsigned array, 16-bit signed array, 32-bit signed array and 32-bit signed array. 2) Fill in all the blanks in Table 1 using your completed code, following the hints provided within the table. 3) Fill in all the blanks in Table 2 using your completed code, following the hints provided within the table. C++ Program #include <stdio.h> #include <iostream> int...

  • in C Structures Homework 1. Write code to accomplish each of the following: a) Using t...

    in C Structures Homework 1. Write code to accomplish each of the following: a) Using t ypedef, declare a structure, Automobile, with the following members: mode1 - string of 25 characters maximum year - integer mpg - integer b) Declare variable car to be of type Automobile. c) Assign the information below to the appropriate fields of variable car: 2012 Infiniti gets 25 mpg. d) Declare an array, vehicle, of 500 Automobiles. e) Assign variable car to the 5th element...

  • Suppose v is an array with 100 int elements. If 100 is assigned to v[100], what happens? Show the code. An array of 1000 integers is declared. What is the largest integer that can be used as an index...

    Suppose v is an array with 100 int elements. If 100 is assigned to v[100], what happens? Show the code. An array of 1000 integers is declared. What is the largest integer that can be used as an index to the array? Shows the code. Consider the declaration: int v[1]; What is the index of the last element of this array? Declare an array named a of 10 int elements and initialize the elements (starting with the first) to the...

  • Using Atmel studio 7 -C language programming Write a program to find the median of an...

    Using Atmel studio 7 -C language programming Write a program to find the median of an array of 8-bit unsigned integers. When the array has an even number of elements, the median is defined as the average of the middle two elements. Otherwise, it is defined as the middle element of the array. You need to sort the array in order to find the median. SHOW THAT THE CODE IS WORKING PROPERLY IN ATMEL STUDIO 7

  • Using C programming

    Using C, create a data file with the first number being an integer. The value of that integer will be the number of further integers which follow it in the file. Write the code to read the first number into the integer variable how_many.Please help me with the file :((This comes from this question:Write the code to dynamically allocate ONE integer variable using calloc (contiguous allocation) or malloc (memory allocation) and have it pointed to by a pointer (of type int...

  • Using Structures in C language programming

    Write code to accomplish each of the following:Define a structure called Dove containing int variable dovNo and char array dovArr with values that may be as long as 25 characters (including the terminating null character).Define dove to be a synonym for the type struct Dove.Use Dove to declare variable a to be of type struct Dove, array b[ 10 ] to be of type struct Dove and variable ptr to be of type pointer to struct Dove.Read a dovNo and a dovArr from the keyboard into the individual members of variable a.Assign the member values of variable a to element 3 of array b.Assign the address...

  • Hi!, having trouble with this one, In this class we use visual studio, C++ language --------------------------------------------------------------...

    Hi!, having trouble with this one, In this class we use visual studio, C++ language -------------------------------------------------------------- Exercise #10 Pointers - Complete the missing 5 portions of part1 (2 additions) and part2 (3 additions) Part 1 - Using Pointers int largeArray (const int [], int); int largePointer(const int * , int); void fillArray (int * , int howMany); void printArray (const char *,ostream &, const int *, int howMany); const int low = 50; const int high = 90; void main()...

  • I NEED HELP WITH C PROGRAMMING. Answer each of the following. Assume that unsigned integers are...

    I NEED HELP WITH C PROGRAMMING. Answer each of the following. Assume that unsigned integers are stored in 4 bytes and that the starting address of the array is at location 200 600 in memory. i)What address is referenced by vPtr + 5? What value is stored at that location? j) Assuming vPtr points to values[6] , what address is referenced by vPtr -= 4? What value is stored at that location? Also ..... For each of the following, write...

  • please use c ++ language and write the comment too. thanks Pointer Arithmetic Write a function...

    please use c ++ language and write the comment too. thanks Pointer Arithmetic Write a function that passes an array address to a function as a pointer. Using pointer arithmetic, the function determines the average, high, and low value of the array. Your function should have this header: void pointerArithmetic(int *array, int size, double &average, int &high, int &low) Parameter size is the number of elements in array. You may not use the subscript notation [] inside your function –...

  • Make one program using Dev c++, and explain how program works Final Program Requirements: Declare an...

    Make one program using Dev c++, and explain how program works Final Program Requirements: Declare an int variable and int array with four elements in the main program. Initial values for the intvariable and int array are hardcoded in the program. Declare an int pointer in the main program.Program shows the values of the integer variable and integer arrayelements. Program shows the addresses of the variable and each integer array element. Store addresses inpointers temporarily prior to displaying. The addresses...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT