MyProgrammingLab 9-1 Transcript

Print

All right, so come on over here to the arrow, or actually the plus sign, next to Chapter 9 pointers. Then we're going to go here to 9.1, and this is getting the address of a variable. You can actually resize the window by grabbing the edge like that. You can also resize this way by grabbing the edge like that. All right, so once you have that, go ahead and click on the 10692. 

Then it says "Assume a variable diff has already been declared. Write an expression whose value is the address of diff." Now, how do you say address of? You say address using the ampersand. That gives the memory address location of the variable, and what is the variable? The variable is diff. So we're going to say, "address of diff", and this will actually give us back a hexadecimal address of the variable, diff. 

Just to show you what that looks like with Visual Studio 2015. And we create a new project. C ++. And we hit Empty Project, and then this is going to be Week 1 MyProgrammingLab Testing; I'm going to flip it over to my desktop. It creates a project for me. I right click on Source Files. I hit Add a New Item, and it's going to be a C++ file, and leave the name as Source. So up here, I'm going to bring in and actually bring in my information. 

So the slash star, star slash, is a comment block. So I type in my information, and then the CEIS 190, and this is Testing Application for MyProgrammingLab. All right, so now, down here, I want to bring in the IO stream, and then I'm going to bring in the string library. I probably won't need it for this application. Then using "namespace std". And then three slashes is a documentation comment, so, on a document, my method, and the main is the entry point for the application. So, I say "ent main", further brace enter key. 

And then I want to pause, so, to pause, I'm simply going to say "cout endl". And, actually, I think I want to pause different way. Backslash N. Press any key to continue. 

And then, I'm going to say "underscore get CH" and then "return zero". And the get CH belongs to the console input output header, so I need to bring that in like that. 

All right, so if I run it, you can see that my application pauses. Now, this right here project is out of date. Would you like to build it? I always want to build it, so, I'll put a check mark there. I'm going to hit Yes, and my application pauses. 

All right, so now, with this assignment is saying, is it's saying is that you have a variable called diff that's already been created. The variable diff has already been created. And so, I'm going to just make it an "ent", and I'm going to initialize it to zero. Now it says, "get the address of diff", so I want to say "cout" the memory address, and that's going to be a hexadecimal. The hexadecimal number is, and then I'm going to say the address of the diff variable, like that. 

All right, so that's going to literally tell me where in my memory stick, where in my RAM, this variable, it has been created. All right, so I'm going to run it, and you can see that it's going to be a hexadecimal number. There it is. Zero, zero, E F F A C 4. Now, hexadecimal numbers are base 16, and you'll learn more about hexadecimal numbers if you don't already know hexadecimal numbers. So you can see that the memory address is zero zero E F F A C 4. Now, how did I get that memory address? I remembered that the ampersand means "address of". 

Okay, so this is the correct answer for, whoops, this is the correct answer to get the address of the diff variable. So if I hit submit, come on, baby. All right, there it is. There's a correct answer. All right.

[End of Audio]