Question

In: Computer Science

use cout to print the address at which the following array is stored in memory long...

use cout to print the address at which the following array is stored in memory

long double computers[24]

a. print the adress of the last element

b. print the address of the tenth element.

c. print the address of the first element in the array

Solutions

Expert Solution

/* ADDRESS MAY BE DIFFERENT IN DIFFERENT COMPUTERS */

#include<iostream>
using namespace std;

int main(){
   long double computers[24];
   // in C++ array index starts from 0
   // so index is from 0 to 23
   cout << "Address of last element: "<<&computers[23]<<endl;
   cout << "Address of the tenth element: "<<&computers[9]<<endl;
   cout << "Address of the first element: "<<&computers[0]<<endl;
   return 0;
}

/* OUTPUT */

/* PLEASE UPVOTE */


Related Solutions

THE CODE IN THIS QUESTION IS STORED IN THE MEMORY FROM ADDRESS 0X1FFF000. SO TAKE THIS...
THE CODE IN THIS QUESTION IS STORED IN THE MEMORY FROM ADDRESS 0X1FFF000. SO TAKE THIS INTO CONSIDERATION. 1.     In the following MIPS assembly code, translate all the instructions to their corresponding machine code in hexadecimal format. This code is stored in the memory from address 0x1fff0000. Loop: sw $t1, 4($s0)        addi $t1, $t1, -1    sll $t1, $t1, 2        bne $t1, $s5, Exit    addi $s0, $s0, 4          j Loop Exit: … ********************************THE FOLLOWING...
The following code segment is stored in memory starting at memory location 0x00445670. What are the...
The following code segment is stored in memory starting at memory location 0x00445670. What are the two possible values for the contents of the PC after the branch instruction has executed?       bgez $a0, skip                      # mem location: 0x00445670 subu $s2, $s1, $t0 # branch NOT taken (false) ori    $v0, $t1, 0x0003 #       skip: addi $t0, $t1, 2 # branch taken (true) if taken: if not taken: Hint: Remember how many bytes each instructions takes.
write a program which will prompt an array of 12 integers then print the array as...
write a program which will prompt an array of 12 integers then print the array as an array of 4 columns on 3 rows
Discuss flashbulb memories and the idea that all memories are stored permanently in long-term memory.
Discuss flashbulb memories and the idea that all memories are stored permanently in long-term memory.
5C++ Questions 1. What will the following code print? num = 8; cout << --num <<...
5C++ Questions 1. What will the following code print? num = 8; cout << --num << " "; cout << num++ << " "; cout << num; 2.Since the while loop evaluates the condition before executing the statement(s), it is known as a(n)____ loop, whereas the do-while loop evaluates the condition after the statements have been executed, it is known as a(n)____ loop. 3.T/F While loops can only be used when a counter is decremented to zero. If the counter...
Consider a memory system with a 14 bit long address. Produce the answer to each of...
Consider a memory system with a 14 bit long address. Produce the answer to each of the following parts using hexadecimal numbers. a. There is a 1.5k byte RAM device, starting at address $200. What is its last address? b. There is a 1k byte EPROM device, starting at address $900.What is is last address? c. There is a 7k byte ROM device, its last address is at the highest system address. What is its first address? d. Use your...
D-Latch is a simple clocked memory element in which the output is equal to the stored...
D-Latch is a simple clocked memory element in which the output is equal to the stored state inside the element. In D-Latch the state is changed whenever the appropriate inputs change and the clock is asserted. A D-Latch has two inputs and two outputs. The inputs are the data value to be stored and a clock signal that indicates when the latch should read the value on the data input and store it. The outputs are simply the value of...
D-Latch is a simple clocked memory element in which the output is equal to the stored...
D-Latch is a simple clocked memory element in which the output is equal to the stored state inside the element. In D-Latch the state is changed whenever the appropriate inputs change and the clock is asserted. A D-Latch has two inputs and two outputs. The inputs are the data value to be stored and a clock signal that indicates when the latch should read the value on the data input and store it. The outputs are simply the value of...
Why would memory indirect addressing (i.e., the instruction contains a memory address A, which in turn...
Why would memory indirect addressing (i.e., the instruction contains a memory address A, which in turn is a pointer to memory location B which contains the value) be difficult to implement on the hardware in Figure 5.8?
Dynamic Array (4 marks) To save computer memory, we need to use dynamic array. In the...
Dynamic Array To save computer memory, we need to use dynamic array. In the first version of our stack implementation, the instance variable has a fixed capacity, which is 128. There will be an error when the stack is bigger than 128. For bigger data, you increased the array size. But that very long array could be wasted for smaller data. In order to solve this dilemma, we start with a small array, and increase the capacity only when it...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT