Question: Escribir un programa en C++ que: Declare un array de 5 enteros. Compruebe la cantidad de bytes sucesivos que ocupan en memoria, escribiendo sus direcciones.

Escribir un programa en C++ que:

Declare un array de 5 enteros.

Compruebe la cantidad de bytes sucesivos que ocupan en memoria, escribiendo sus direcciones.

Declare dos punteros a entero y les asigne las direcciones del primer y ltimo elemento del array.

Imprima la diferencia entre ambos punteros.

Incremente en una unidad el puntero que apunta al primer elemento, y compruebe que la direccin de memoria apuntada se ha incrementado en cuatro unidades. (Por ser puntero a entero).

Imprima el contenido de la direccin de memoria apuntada por el puntero.

Ejemplo : La direccion asignada a x[0] es 00x61fef0

La direccion asignada a x[1] es 10x61fef4

La direccion asignada a x[2] es 20x61fef8

La direccion asignada a x[3] es 30x61fefc

La direccion asignada a x[4] es 40x61ff00

La diferencia entre punteros es:-4

La diferencia entre direcciones es: 4

ENGLISH:

Write a C++ program that:

Declare an array of 5 integers.

Check the number of successive bytes they occupy in memory by writing their addresses.

Declare two pointers to integers and assign them the addresses of the first and last elements of the array.

Print the difference between both pointers.

Increment the pointer to the first element by one, and check that the memory address pointed to has been increased by four units. (Because it is a pointer to an integer).

Print the content of the memory address pointed to by the pointer.

Example : The address assigned to x[0] is 00x61fef0

The address assigned to x[1] is 10x61fef4

The address assigned to x[2] is 20x61fef8

The address assigned to x[3] is 30x61fefc

The address assigned to x[4] is 40x61ff00

The difference between pointers is: -4

The difference between addresses is: 4

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!