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

Similar to Variables and Types in Objective-C and C Programming (20)

PDF
Numbers and Values in Objective-C and C Programming
PPT
02 Primitive data types and variables
PDF
Functions in Objective-C and C Programming
PPTX
Spf Chapter4 Variables
PPTX
PPTX
02. Primitive Data Types and Variables
PPTX
5variables in c#
PPT
Structured Programming with C - Data Types.ppt
PDF
Session 2 - Objective-C basics
PPTX
Lesson 4 Basic Programming Constructs.pptx
PPTX
COM1407: Variables and Data Types
DOCX
Data Type is a basic classification which identifies.docx
PPTX
Data Types, Variables, and Constants in C# Programming
PDF
NUS iOS Swift Talk
PPT
Data type in c
PPTX
PPS_unit_2_gtu_sem_2_year_2023_GTUU.pptx
PPT
cs8251 unit 1 ppt
PPT
Csharp4 basics
PPTX
Constant, variables, data types
PPTX
data types in C-Sharp (C#)
Numbers and Values in Objective-C and C Programming
02 Primitive data types and variables
Functions in Objective-C and C Programming
Spf Chapter4 Variables
02. Primitive Data Types and Variables
5variables in c#
Structured Programming with C - Data Types.ppt
Session 2 - Objective-C basics
Lesson 4 Basic Programming Constructs.pptx
COM1407: Variables and Data Types
Data Type is a basic classification which identifies.docx
Data Types, Variables, and Constants in C# Programming
NUS iOS Swift Talk
Data type in c
PPS_unit_2_gtu_sem_2_year_2023_GTUU.pptx
cs8251 unit 1 ppt
Csharp4 basics
Constant, variables, data types
data types in C-Sharp (C#)
Ad

Recently uploaded (20)

PPTX
Microbial diseases, their pathogenesis and prophylaxis
PDF
LDMMIA Reiki Yoga Finals Review Spring Summer
PDF
RMMM.pdf make it easy to upload and study
PPTX
UV-Visible spectroscopy..pptx UV-Visible Spectroscopy – Electronic Transition...
PPTX
Tissue processing ( HISTOPATHOLOGICAL TECHNIQUE
PDF
Trump Administration's workforce development strategy
PDF
A systematic review of self-coping strategies used by university students to ...
DOC
Soft-furnishing-By-Architect-A.F.M.Mohiuddin-Akhand.doc
PDF
01-Introduction-to-Information-Management.pdf
PDF
2.FourierTransform-ShortQuestionswithAnswers.pdf
PDF
STATICS OF THE RIGID BODIES Hibbelers.pdf
PPTX
Cell Types and Its function , kingdom of life
PDF
A GUIDE TO GENETICS FOR UNDERGRADUATE MEDICAL STUDENTS
PDF
The Lost Whites of Pakistan by Jahanzaib Mughal.pdf
PDF
Complications of Minimal Access Surgery at WLH
PPTX
master seminar digital applications in india
PPTX
school management -TNTEU- B.Ed., Semester II Unit 1.pptx
PPTX
1st Inaugural Professorial Lecture held on 19th February 2020 (Governance and...
PPTX
History, Philosophy and sociology of education (1).pptx
PDF
OBE - B.A.(HON'S) IN INTERIOR ARCHITECTURE -Ar.MOHIUDDIN.pdf
Microbial diseases, their pathogenesis and prophylaxis
LDMMIA Reiki Yoga Finals Review Spring Summer
RMMM.pdf make it easy to upload and study
UV-Visible spectroscopy..pptx UV-Visible Spectroscopy – Electronic Transition...
Tissue processing ( HISTOPATHOLOGICAL TECHNIQUE
Trump Administration's workforce development strategy
A systematic review of self-coping strategies used by university students to ...
Soft-furnishing-By-Architect-A.F.M.Mohiuddin-Akhand.doc
01-Introduction-to-Information-Management.pdf
2.FourierTransform-ShortQuestionswithAnswers.pdf
STATICS OF THE RIGID BODIES Hibbelers.pdf
Cell Types and Its function , kingdom of life
A GUIDE TO GENETICS FOR UNDERGRADUATE MEDICAL STUDENTS
The Lost Whites of Pakistan by Jahanzaib Mughal.pdf
Complications of Minimal Access Surgery at WLH
master seminar digital applications in india
school management -TNTEU- B.Ed., Semester II Unit 1.pptx
1st Inaugural Professorial Lecture held on 19th February 2020 (Governance and...
History, Philosophy and sociology of education (1).pptx
OBE - B.A.(HON'S) IN INTERIOR ARCHITECTURE -Ar.MOHIUDDIN.pdf
Ad

Variables and Types in Objective-C and C Programming