SlideShare a Scribd company logo
Paul Solt
iPhoneDev.tv
Variables andTypes
The buildings blocks of apps
Paul Solt
iPhoneDev.tv
Coffee
=+
Paul Solt
iPhoneDev.tv
Coffee
•17 ml water : 1 g coffee
•950 ml water / 17 ml/g = ?
•55.8 g coffee
Paul Solt
iPhoneDev.tv
Variables
Give the CPU something to remember
Paul Solt
iPhoneDev.tv
// Declare a variable to store water
float water;
// Store the amount of water to use
water = 950; // milliliters
// Display message
printf("Brew %f milliliters of coffee", water);
Paul Solt
iPhoneDev.tv
int age = 26;
Paul Solt
iPhoneDev.tv
int age = 26;
type
Paul Solt
iPhoneDev.tv
int age = 26;
type name
Paul Solt
iPhoneDev.tv
int age = 26;
type name expression
Paul Solt
iPhoneDev.tv
int age = 26;
type name expression
assignment
operator
Paul Solt
iPhoneDev.tv
int age = 26;
Paul Solt
iPhoneDev.tv
int age = 26;
26age
Paul Solt
iPhoneDev.tv
int a;
int b;
a = 5;
b = 20;
b = 5 + b;
a = a - b;
Paul Solt
iPhoneDev.tv
int a;
int b;
a = 5;
b = 20;
b = 5 + b;
a = a - b;
a
Paul Solt
iPhoneDev.tv
int a;
int b;
a = 5;
b = 20;
b = 5 + b;
a = a - b;
a
b
Paul Solt
iPhoneDev.tv
int a;
int b;
a = 5;
b = 20;
b = 5 + b;
a = a - b; b
5a
Paul Solt
iPhoneDev.tv
int a;
int b;
a = 5;
b = 20;
b = 5 + b;
a = a - b;
5a
20b
Paul Solt
iPhoneDev.tv
int a;
int b;
a = 5;
b = 20;
b = 5 + b;
a = a - b;
5a
20
5+b
b
Paul Solt
iPhoneDev.tv
int a;
int b;
a = 5;
b = 20;
b = 5 + b;
a = a - b;
5a
20
5+20
b
Paul Solt
iPhoneDev.tv
int a;
int b;
a = 5;
b = 20;
b = 5 + b;
a = a - b;
5a
25
5+20
b
Paul Solt
iPhoneDev.tv
int a;
int b;
a = 5;
b = 20;
b = 5 + b;
a = a - b;
5a
25b
Paul Solt
iPhoneDev.tv
int a;
int b;
a = 5;
b = 20;
b = 5 + b;
a = a - b;
5
a-b
a
25b
Paul Solt
iPhoneDev.tv
int a;
int b;
a = 5;
b = 20;
b = 5 + b;
a = a - b;
5
5-25
a
25b
Paul Solt
iPhoneDev.tv
int a;
int b;
a = 5;
b = 20;
b = 5 + b;
a = a - b;
-20
5-25
a
25b
Paul Solt
iPhoneDev.tv
int a;
int b;
a = 5;
b = 20;
b = 5 + b;
a = a - b;
-20a
25b
Paul Solt
iPhoneDev.tv
Types
What kind of information are we storing?
Paul Solt
iPhoneDev.tv
•short/int/long: -1,0,1
•float/double: 3.14
•char: ‘a’, ‘b’, ‘c’
•pointers: int * (memory address)
•struct: composition (x, y)
Paul Solt
iPhoneDev.tv
short small = 12;
int medium = 2000000;
long large = 90133726844735000;
Paul Solt
iPhoneDev.tv
float smaller = 3.14;
double larger = 3.14159265359;
Paul Solt
iPhoneDev.tv
char firstLetter = 'a';
char percent = '%';
Paul Solt
iPhoneDev.tv
int *address = 0;
int x = 18;
address = &x;
*address = 27;
address x
0x1234 0x5544
Paul Solt
iPhoneDev.tv
int *address = 0;
int x = 18;
address = &x;
*address = 27;
address x
0x1234 0x5544
0
Paul Solt
iPhoneDev.tv
int *address = 0;
int x = 18;
address = &x;
*address = 27;
address x
0x1234 0x5544
0 18
Paul Solt
iPhoneDev.tv
int *address = 0;
int x = 18;
address = &x;
*address = 27;
address x
0x1234 0x5544
0 18
Paul Solt
iPhoneDev.tv
int *address = 0;
int x = 18;
address = &x;
*address = 27;
address x
0x1234 0x5544
&x
0 18
Paul Solt
iPhoneDev.tv
int *address = 0;
int x = 18;
address = &x;
*address = 27;
address x
0x1234 0x5544
0x5544
&x
18
Paul Solt
iPhoneDev.tv
int *address = 0;
int x = 18;
address = &x;
*address = 27;
address x
0x1234 0x5544
0x5544
&x
18
Paul Solt
iPhoneDev.tv
int *address = 0;
int x = 18;
address = &x;
*address = 27;
address x
0x1234 0x5544
0x5544 18
*address
Paul Solt
iPhoneDev.tv
int *address = 0;
int x = 18;
address = &x;
*address = 27;
address x
0x1234 0x5544
0x5544 27
*address
Paul Solt
iPhoneDev.tv
int *address = 0;
int x = 18;
address = &x;
*address = 27;
address x
0x1234 0x5544
0x5544 27
Paul Solt
iPhoneDev.tv
struct Point {
int x;
int y;
};
...
struct Point a;
a.x = 25;
a.y = 100;
Paul Solt
iPhoneDev.tv
struct Point {
int x;
int y;
};
...
struct Point a;
a.x = 25;
a.y = 100;
(25, 100)
y
x
Paul Solt
iPhoneDev.tv
•short/int/long: -1,0,1
•float/double: 3.14
•char: ‘a’, ‘b’, ‘c’
•pointers: int * (memory address)
•struct: composition (x, y)
Paul Solt
iPhoneDev.tv

More Related Content

PPTX
The underdog
PPTX
Prosiect llythrennedd gwybodaeth cymru v2.2
PPTX
Information Literacy By Stealth
PDF
Xcode for Non-Programmers - Learn How to Build iPhone Apps
PPTX
InfoLit in FE Best Practice Event
PPT
Modul ev-pbm-tp-2008
PPTX
The twilight saga
PPS
Api a scuola
The underdog
Prosiect llythrennedd gwybodaeth cymru v2.2
Information Literacy By Stealth
Xcode for Non-Programmers - Learn How to Build iPhone Apps
InfoLit in FE Best Practice Event
Modul ev-pbm-tp-2008
The twilight saga
Api a scuola

Recently uploaded (20)

PDF
Abdominal Access Techniques with Prof. Dr. R K Mishra
PDF
Computing-Curriculum for Schools in Ghana
PDF
O5-L3 Freight Transport Ops (International) V1.pdf
PPTX
Pharma ospi slides which help in ospi learning
PPTX
PPH.pptx obstetrics and gynecology in nursing
PPTX
Renaissance Architecture: A Journey from Faith to Humanism
PDF
Microbial disease of the cardiovascular and lymphatic systems
PPTX
1st Inaugural Professorial Lecture held on 19th February 2020 (Governance and...
PDF
Classroom Observation Tools for Teachers
PDF
Saundersa Comprehensive Review for the NCLEX-RN Examination.pdf
PPTX
Pharmacology of Heart Failure /Pharmacotherapy of CHF
PDF
STATICS OF THE RIGID BODIES Hibbelers.pdf
PPTX
IMMUNITY IMMUNITY refers to protection against infection, and the immune syst...
PPTX
Microbial diseases, their pathogenesis and prophylaxis
PDF
Basic Mud Logging Guide for educational purpose
PDF
Anesthesia in Laparoscopic Surgery in India
PPTX
school management -TNTEU- B.Ed., Semester II Unit 1.pptx
PDF
TR - Agricultural Crops Production NC III.pdf
PDF
Pre independence Education in Inndia.pdf
PPTX
Lesson notes of climatology university.
Abdominal Access Techniques with Prof. Dr. R K Mishra
Computing-Curriculum for Schools in Ghana
O5-L3 Freight Transport Ops (International) V1.pdf
Pharma ospi slides which help in ospi learning
PPH.pptx obstetrics and gynecology in nursing
Renaissance Architecture: A Journey from Faith to Humanism
Microbial disease of the cardiovascular and lymphatic systems
1st Inaugural Professorial Lecture held on 19th February 2020 (Governance and...
Classroom Observation Tools for Teachers
Saundersa Comprehensive Review for the NCLEX-RN Examination.pdf
Pharmacology of Heart Failure /Pharmacotherapy of CHF
STATICS OF THE RIGID BODIES Hibbelers.pdf
IMMUNITY IMMUNITY refers to protection against infection, and the immune syst...
Microbial diseases, their pathogenesis and prophylaxis
Basic Mud Logging Guide for educational purpose
Anesthesia in Laparoscopic Surgery in India
school management -TNTEU- B.Ed., Semester II Unit 1.pptx
TR - Agricultural Crops Production NC III.pdf
Pre independence Education in Inndia.pdf
Lesson notes of climatology university.
Ad
Ad

Variables and Types in Objective-C and C Programming