From the course: Computer Science Principles: Programming

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Work with values and variables

Work with values and variables

From the course: Computer Science Principles: Programming

Start my 1-month free trial

Work with values and variables

- Computers store, process, and access data and information. In a computer program, a programmer does this with variables. Variables have two sides to them. For the programmer, it is a name that you use to refer to a value throughout your program. The computer then reserves an amount of space in memory to store that value and make it available to you as a programmer. The easiest value to think of is a number, like the number three. Three is a number of things, like three paperclips. The number three is called an integer. An integer is a whole number that counts the number of objects or things. With an integer, I can add to it or subtract from it. There are two types of integers, however: unsigned and signed. When you think of three paperclips, you don't think in terms of positive or negative. You just simply have three paperclips. But if I used to have five paperclips, and now I have three, how would I represent the change in value? I would use a negative number to indicate that I…

Contents