Question

Assume that x is at memory location 0x61fe18, and xptr is at memory location 0x61fe10. What...

Assume that x is at memory location 0x61fe18, and xptr is at memory location 0x61fe10.

What is printed by the below snippet of code?

int x;
int * xptr;
xptr = & x;
x = 12;

cout << x << endl;
cout << xptr << endl;
cout << &x << endl;
cout << &xptr << endl;
cout << *xptr << endl;

Homework Answers

Answer #1
cout << x << endl; this will print 12 the value of x
cout << xptr << endl; this will print 0x61fe18 the memory address of x
cout << &x << endl; this will also print 0x61fe18 the memory address of x
cout << &xptr << endl; this will print 0x61fe10 the memory address of xptr
cout << *xptr << endl; this will print 12 the value stored at memory address 0x61fe18  ( of x)

So the output will look like

12

0x61fe18

0x61fe18

0x61fe10

12

Thanks.

Know the answer?
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
Similar Questions
Assuming that a user enters 64 as his marks obtained, what is the output of the...
Assuming that a user enters 64 as his marks obtained, what is the output of the following code snippet? int main() { int score = 0; cout << "Enter your score: "; cin >> score; if (score < 40) { cout << "F" << endl; } else if (score < 50) { cout << "D" << endl; } else if (score < 60) { cout << "C" << endl; } else if (score < 70) { cout << "B" <<...
We discussed in the class that there are 3 major issues with pointers and dynamic memory...
We discussed in the class that there are 3 major issues with pointers and dynamic memory allocations . Memory fault: Invalid memory access   Memory leak Memory corruption Identify the line numbers in the code snippet below for each issue listed above with one line explaining your reason. A sample answer: - Memory fault: line number 6: because a for-loop can't iterate more than 1,000,000 - Memory leak: line number 9; because .... - Memory corruption: line number 7; because .......
Write the C55x assembly code for each of the following C snippet code shown below. Assume...
Write the C55x assembly code for each of the following C snippet code shown below. Assume the 8-bit values a, b, c, and d are stored in locations 0x600, 0x601, 0x602, and 0x603 respectively in the memory. Store the result x in location 0x604 and y in location 0x60C. Do not use software to generate the assembly code and comment your code. x = (a - b)3 - (c*d); for (j=0;j<=200;j++)   y = y + (a * b);
Write a program that prompts the user to input a string and outputs the string in...
Write a program that prompts the user to input a string and outputs the string in uppercase letters. (Use dynamic arrays to store the string.) my code below: /* Your code from Chapter 8, exercise 5 is below. Rewrite the following code to using dynamic arrays. */ #include <iostream> #include <cstring> #include <cctype> using namespace std; int main() { //char str[81]; //creating memory for str array of size 80 using dynamic memory allocation char *str = new char[80]; int len;...
Please find the errors of the following code a) int x[5]; int k = 10; for...
Please find the errors of the following code a) int x[5]; int k = 10; for (k = 0; k <= 5; k++) { x[k] = k -1; } b) int x[5]; for (k = 1; k <= 5; k++) { cout << x[k-1] << endl; } c) int x[5]={1,2,3,4,5}, y[5]; y = x; for (k = 0; k < 5; k++) { cout << y[k] << endl; } d) int size; cin >> size; int myArr[size];
For different input n, i.e., n = 1, n = 10, n = 20, write down...
For different input n, i.e., n = 1, n = 10, n = 20, write down the final value of counter for function1, function2, and function3. Explain the counter result through math calculation. #include <iostream> using namespace std; void function1(int n){ int count = 0; for(int x = 0; x < 12; x++){ cout<<"counter:"<< count++<<endl; } } void function2(int n){ int count = 0; for(int x = 0; x < n; x++){ cout<<"--- x="<<x<<"------"<<endl; for(int i =0; i < n;...
Given the following function in C++: int main(void) { int a = 2; int b =...
Given the following function in C++: int main(void) { int a = 2; int b = myFunction(a); a = b + 1; b = myFunction(a); cout << ”b = ” << b << endl; return 0; } int z = myFunction(int x) { static int n = 0; n = n + 1; int z = x + n; return z; } What is printed by the cout on the screen?
C++ please Write code to implement the Karatsuba multiplication algorithm in the file linked in Assignment...
C++ please Write code to implement the Karatsuba multiplication algorithm in the file linked in Assignment 2 (karatsuba.cpp) in Canvas (please do not rename file or use cout/cin statements in your solution). As a reminder, the algorithm uses recursion to produce the results, so make sure you implement it as a recursive function. Please develop your code in small The test program (karatsuba_test.cpp) is also given. PLEASE DO NOT MODIFY THE TEST FILE. KARATSUBA.CPP /* Karatsuba multiplication */ #include <iostream>...
C++ question. Please explain the code and how it resulted in the output. Explain each line...
C++ question. Please explain the code and how it resulted in the output. Explain each line along with the aspects of "buffers" if possible. Everything is listed below. Code below: #include <iostream> #include <string> using namespace std; int main() {    cout << boolalpha;    cout << static_cast<bool>(1) << endl;    cout << static_cast<bool>(0) << endl;    string s = "AAARGH!!!";    if (s.find("AAA")) { cout << 1 << endl; }    if (s.find("RGH")) { cout << 2 << endl;...
Computer archieture 1. Given this piece of code fragment: for (int x = 0; x <...
Computer archieture 1. Given this piece of code fragment: for (int x = 0; x < 10; x++) {     if (x >= 5)         cout << "OK" << endl; } Assuming the branch prediction by default is “TAKEN”, What is the accuracy of branch prediction of the cout statement when we use a 1-bit branch history? What is the accuracy of branch prediction of the cout statement when we use a 2-bit branch history?
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT