Presentation is loading. Please wait.

Presentation is loading. Please wait.

Variables and Computer Memory

Similar presentations


Presentation on theme: "Variables and Computer Memory"— Presentation transcript:

1 Variables and Computer Memory
In most all computers, your program and your data (variables) are stored in the computer’s memory (you can read about it here) like in the picture on the right. Each location in memory has an address (a number) numbered from 0 to however big your memory is (e.g., say you have 2GB of memory, then the addresses are from 0 to 2GB). Now, it’d be a real pain to have to keep track of all the memory address you might use in a program, but the good news is that you don’t have to do this, because you can name memory locations and then just use the names. This is what a variable declaration does, it names a piece of memory and tells the computer what you want to keep there (e.g., a character, a string, an integer, etc.). Once a variable is declared, you can refer to it or change it as often as you want to make the computer program do what you want. int a; int b = 5; double x = 4.23; bool myVar = true; char c = ‘?’; string n = “Joe”; Memory n: Joe At address 0x0 c: ? myVar: true b: 5 x: 4.23 addr 0xBE680C 0x a:


Download ppt "Variables and Computer Memory"

Similar presentations


Ads by Google