0% found this document useful (0 votes)
10 views

Data Types Variables and Constants

This document discusses data types, variables, and constants in programming. It covers several key points: 1) Data types tell us how to interpret binary representations and determine valid operations for values. They allow programs to interpret bits appropriately. 2) Variables and constants are declared to allocate memory space for storing values. Variables can change during a program's execution while constants cannot. 3) The main data types discussed are numeric types like integers. Variable declarations provide a name and data type, optionally an initial value, while constant declarations require an initial value known at compile time.

Uploaded by

Luca Kab
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views

Data Types Variables and Constants

This document discusses data types, variables, and constants in programming. It covers several key points: 1) Data types tell us how to interpret binary representations and determine valid operations for values. They allow programs to interpret bits appropriately. 2) Variables and constants are declared to allocate memory space for storing values. Variables can change during a program's execution while constants cannot. 3) The main data types discussed are numeric types like integers. Variable declarations provide a name and data type, optionally an initial value, while constant declarations require an initial value known at compile time.

Uploaded by

Luca Kab
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 12

Module 3

Data Types, Variables, and


Constants

Lecture
Data Types, Variables, and
Constants

Module 3 Learning Objectives



Remember from the previous lecture that
everything in a computer is represented in binary

In-Lecture Quiz

If we have b bits, how many distinct values can we
represent?
A: 2
b
B: log
2
b
C: 8
D: 1024


What does 01000001
mean?
It depends on how we
interpret it
Could mean 65
Could mean A
Could mean a lot of
other things!
The data type of a
variable or constant tells
us how to interpret the
bits
Data type also
determines the valid
operations for the value
Adding an integer to a
pixel value (almost)
never makes sense
Theres always an
exception!
42
41
43
44
45
40 01000001
11010101
00000000
01110101
10011001
01010101


How do we get a space in memory, that we can
refer to by name rather than memory address,
with bits that will be interpreted the way we want
them to be?


In-Lecture Quiz

We get memory allocated for a variable in C# by doing
what to the variable?
A: defining it
B: declaring it
C: desalinizing it
D: beating it with a stick

When we declare a
variable we provide the
data type and the
variable name
Optionally, we provide
a value as well
When we declare a
constant we provide the
data type, the constant
name, and the value
In-Lecture Quiz
Whats the difference between variables and constants?
A: The value of a variable can change while we run the
program and the variable of a constant cant
B: Variables are variable and constants are constant
C: The compiler has to know the value of a constant at
compile time
D: Variables are green and constants are blue


Recap
Data types tell us how to interpret the bits and what
operations are valid for the value the bits represent
We declare variable and constants to get memory
space for values we need to store
Next Time
Numeric data types

You might also like