variables and types in objective-c and c programming
DESCRIPTION
Course Link: http://skl.sh/11kA0im Website: http://iPhoneDev.tv Learn how variables and types work in Objective-C and C programming languages.TRANSCRIPT
![Page 1: Variables and Types in Objective-C and C Programming](https://reader035.vdocuments.site/reader035/viewer/2022081403/555e368ed8b42aad058b48bf/html5/thumbnails/1.jpg)
Paul Solt iPhoneDev.tv
Variables and TypesThe buildings blocks of apps
![Page 2: Variables and Types in Objective-C and C Programming](https://reader035.vdocuments.site/reader035/viewer/2022081403/555e368ed8b42aad058b48bf/html5/thumbnails/2.jpg)
Paul Solt iPhoneDev.tv
Coffee
=+
![Page 3: Variables and Types in Objective-C and C Programming](https://reader035.vdocuments.site/reader035/viewer/2022081403/555e368ed8b42aad058b48bf/html5/thumbnails/3.jpg)
Paul Solt iPhoneDev.tv
Coffee
•17 ml water : 1 g coffee
•950 ml water / 17 ml/g = ?
•55.8 g coffee
![Page 4: Variables and Types in Objective-C and C Programming](https://reader035.vdocuments.site/reader035/viewer/2022081403/555e368ed8b42aad058b48bf/html5/thumbnails/4.jpg)
Paul Solt iPhoneDev.tv
VariablesGive the CPU something to remember
![Page 5: Variables and Types in Objective-C and C Programming](https://reader035.vdocuments.site/reader035/viewer/2022081403/555e368ed8b42aad058b48bf/html5/thumbnails/5.jpg)
Paul Solt iPhoneDev.tv
// Declare a variable to store waterfloat water;
// Store the amount of water to usewater = 950; // milliliters
// Display messageprintf("Brew %f milliliters of coffee", water);
![Page 6: Variables and Types in Objective-C and C Programming](https://reader035.vdocuments.site/reader035/viewer/2022081403/555e368ed8b42aad058b48bf/html5/thumbnails/6.jpg)
Paul Solt iPhoneDev.tv
int age = 26;
![Page 7: Variables and Types in Objective-C and C Programming](https://reader035.vdocuments.site/reader035/viewer/2022081403/555e368ed8b42aad058b48bf/html5/thumbnails/7.jpg)
Paul Solt iPhoneDev.tv
int age = 26;type
![Page 8: Variables and Types in Objective-C and C Programming](https://reader035.vdocuments.site/reader035/viewer/2022081403/555e368ed8b42aad058b48bf/html5/thumbnails/8.jpg)
Paul Solt iPhoneDev.tv
int age = 26;type name
![Page 9: Variables and Types in Objective-C and C Programming](https://reader035.vdocuments.site/reader035/viewer/2022081403/555e368ed8b42aad058b48bf/html5/thumbnails/9.jpg)
Paul Solt iPhoneDev.tv
int age = 26;type name expression
![Page 10: Variables and Types in Objective-C and C Programming](https://reader035.vdocuments.site/reader035/viewer/2022081403/555e368ed8b42aad058b48bf/html5/thumbnails/10.jpg)
Paul Solt iPhoneDev.tv
int age = 26;type name expression
assignmentoperator
![Page 11: Variables and Types in Objective-C and C Programming](https://reader035.vdocuments.site/reader035/viewer/2022081403/555e368ed8b42aad058b48bf/html5/thumbnails/11.jpg)
Paul Solt iPhoneDev.tv
int age = 26;
![Page 12: Variables and Types in Objective-C and C Programming](https://reader035.vdocuments.site/reader035/viewer/2022081403/555e368ed8b42aad058b48bf/html5/thumbnails/12.jpg)
Paul Solt iPhoneDev.tv
int age = 26;
26age
![Page 13: Variables and Types in Objective-C and C Programming](https://reader035.vdocuments.site/reader035/viewer/2022081403/555e368ed8b42aad058b48bf/html5/thumbnails/13.jpg)
Paul Solt iPhoneDev.tv
int a;int b;a = 5;b = 20;b = 5 + b;a = a - b;
![Page 14: Variables and Types in Objective-C and C Programming](https://reader035.vdocuments.site/reader035/viewer/2022081403/555e368ed8b42aad058b48bf/html5/thumbnails/14.jpg)
Paul Solt iPhoneDev.tv
int a;int b;a = 5;b = 20;b = 5 + b;a = a - b;
a
![Page 15: Variables and Types in Objective-C and C Programming](https://reader035.vdocuments.site/reader035/viewer/2022081403/555e368ed8b42aad058b48bf/html5/thumbnails/15.jpg)
Paul Solt iPhoneDev.tv
int a;int b;a = 5;b = 20;b = 5 + b;a = a - b;
a
b
![Page 16: Variables and Types in Objective-C and C Programming](https://reader035.vdocuments.site/reader035/viewer/2022081403/555e368ed8b42aad058b48bf/html5/thumbnails/16.jpg)
Paul Solt iPhoneDev.tv
int a;int b;a = 5;b = 20;b = 5 + b;a = a - b; b
5a
![Page 17: Variables and Types in Objective-C and C Programming](https://reader035.vdocuments.site/reader035/viewer/2022081403/555e368ed8b42aad058b48bf/html5/thumbnails/17.jpg)
Paul Solt iPhoneDev.tv
int a;int b;a = 5;b = 20;b = 5 + b;a = a - b;
5a
20b
![Page 18: Variables and Types in Objective-C and C Programming](https://reader035.vdocuments.site/reader035/viewer/2022081403/555e368ed8b42aad058b48bf/html5/thumbnails/18.jpg)
Paul Solt iPhoneDev.tv
int a;int b;a = 5;b = 20;b = 5 + b;a = a - b;
5a
205+b
b
![Page 19: Variables and Types in Objective-C and C Programming](https://reader035.vdocuments.site/reader035/viewer/2022081403/555e368ed8b42aad058b48bf/html5/thumbnails/19.jpg)
Paul Solt iPhoneDev.tv
int a;int b;a = 5;b = 20;b = 5 + b;a = a - b;
5a
205+20
b
![Page 20: Variables and Types in Objective-C and C Programming](https://reader035.vdocuments.site/reader035/viewer/2022081403/555e368ed8b42aad058b48bf/html5/thumbnails/20.jpg)
Paul Solt iPhoneDev.tv
int a;int b;a = 5;b = 20;b = 5 + b;a = a - b;
5a
255+20
b
![Page 21: Variables and Types in Objective-C and C Programming](https://reader035.vdocuments.site/reader035/viewer/2022081403/555e368ed8b42aad058b48bf/html5/thumbnails/21.jpg)
Paul Solt iPhoneDev.tv
int a;int b;a = 5;b = 20;b = 5 + b;a = a - b;
5a
25b
![Page 22: Variables and Types in Objective-C and C Programming](https://reader035.vdocuments.site/reader035/viewer/2022081403/555e368ed8b42aad058b48bf/html5/thumbnails/22.jpg)
Paul Solt iPhoneDev.tv
int a;int b;a = 5;b = 20;b = 5 + b;a = a - b;
5a-b
a
25b
![Page 23: Variables and Types in Objective-C and C Programming](https://reader035.vdocuments.site/reader035/viewer/2022081403/555e368ed8b42aad058b48bf/html5/thumbnails/23.jpg)
Paul Solt iPhoneDev.tv
int a;int b;a = 5;b = 20;b = 5 + b;a = a - b;
55-25
a
25b
![Page 24: Variables and Types in Objective-C and C Programming](https://reader035.vdocuments.site/reader035/viewer/2022081403/555e368ed8b42aad058b48bf/html5/thumbnails/24.jpg)
Paul Solt iPhoneDev.tv
int a;int b;a = 5;b = 20;b = 5 + b;a = a - b;
-205-25
a
25b
![Page 25: Variables and Types in Objective-C and C Programming](https://reader035.vdocuments.site/reader035/viewer/2022081403/555e368ed8b42aad058b48bf/html5/thumbnails/25.jpg)
Paul Solt iPhoneDev.tv
int a;int b;a = 5;b = 20;b = 5 + b;a = a - b;
-20a
25b
![Page 26: Variables and Types in Objective-C and C Programming](https://reader035.vdocuments.site/reader035/viewer/2022081403/555e368ed8b42aad058b48bf/html5/thumbnails/26.jpg)
Paul Solt iPhoneDev.tv
TypesWhat kind of information are we storing?
![Page 27: Variables and Types in Objective-C and C Programming](https://reader035.vdocuments.site/reader035/viewer/2022081403/555e368ed8b42aad058b48bf/html5/thumbnails/27.jpg)
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)
![Page 28: Variables and Types in Objective-C and C Programming](https://reader035.vdocuments.site/reader035/viewer/2022081403/555e368ed8b42aad058b48bf/html5/thumbnails/28.jpg)
Paul Solt iPhoneDev.tv
short small = 12;int medium = 2000000;long large = 90133726844735000;
![Page 29: Variables and Types in Objective-C and C Programming](https://reader035.vdocuments.site/reader035/viewer/2022081403/555e368ed8b42aad058b48bf/html5/thumbnails/29.jpg)
Paul Solt iPhoneDev.tv
float smaller = 3.14;double larger = 3.14159265359;
![Page 30: Variables and Types in Objective-C and C Programming](https://reader035.vdocuments.site/reader035/viewer/2022081403/555e368ed8b42aad058b48bf/html5/thumbnails/30.jpg)
Paul Solt iPhoneDev.tv
char firstLetter = 'a';char percent = '%';
![Page 31: Variables and Types in Objective-C and C Programming](https://reader035.vdocuments.site/reader035/viewer/2022081403/555e368ed8b42aad058b48bf/html5/thumbnails/31.jpg)
Paul Solt iPhoneDev.tv
int *address = 0;int x = 18;address = &x;*address = 27;
address x
0x1234 0x5544
![Page 32: Variables and Types in Objective-C and C Programming](https://reader035.vdocuments.site/reader035/viewer/2022081403/555e368ed8b42aad058b48bf/html5/thumbnails/32.jpg)
Paul Solt iPhoneDev.tv
int *address = 0;int x = 18;address = &x;*address = 27;
address x
0x1234 0x5544
0
![Page 33: Variables and Types in Objective-C and C Programming](https://reader035.vdocuments.site/reader035/viewer/2022081403/555e368ed8b42aad058b48bf/html5/thumbnails/33.jpg)
Paul Solt iPhoneDev.tv
int *address = 0;int x = 18;address = &x;*address = 27;
address x
0x1234 0x5544
0 18
![Page 34: Variables and Types in Objective-C and C Programming](https://reader035.vdocuments.site/reader035/viewer/2022081403/555e368ed8b42aad058b48bf/html5/thumbnails/34.jpg)
Paul Solt iPhoneDev.tv
int *address = 0;int x = 18;address = &x;*address = 27;
address x
0x1234 0x5544
0 18
![Page 35: Variables and Types in Objective-C and C Programming](https://reader035.vdocuments.site/reader035/viewer/2022081403/555e368ed8b42aad058b48bf/html5/thumbnails/35.jpg)
Paul Solt iPhoneDev.tv
int *address = 0;int x = 18;address = &x;*address = 27;
address x
0x1234 0x5544&x
0 18
![Page 36: Variables and Types in Objective-C and C Programming](https://reader035.vdocuments.site/reader035/viewer/2022081403/555e368ed8b42aad058b48bf/html5/thumbnails/36.jpg)
Paul Solt iPhoneDev.tv
int *address = 0;int x = 18;address = &x;*address = 27;
address x
0x1234 0x5544
0x5544
&x
18
![Page 37: Variables and Types in Objective-C and C Programming](https://reader035.vdocuments.site/reader035/viewer/2022081403/555e368ed8b42aad058b48bf/html5/thumbnails/37.jpg)
Paul Solt iPhoneDev.tv
int *address = 0;int x = 18;address = &x;*address = 27;
address x
0x1234 0x5544
0x5544
&x
18
![Page 38: Variables and Types in Objective-C and C Programming](https://reader035.vdocuments.site/reader035/viewer/2022081403/555e368ed8b42aad058b48bf/html5/thumbnails/38.jpg)
Paul Solt iPhoneDev.tv
int *address = 0;int x = 18;address = &x;*address = 27;
address x
0x1234 0x5544
0x5544 18*address
![Page 39: Variables and Types in Objective-C and C Programming](https://reader035.vdocuments.site/reader035/viewer/2022081403/555e368ed8b42aad058b48bf/html5/thumbnails/39.jpg)
Paul Solt iPhoneDev.tv
int *address = 0;int x = 18;address = &x;*address = 27;
address x
0x1234 0x5544
0x5544 27*address
![Page 40: Variables and Types in Objective-C and C Programming](https://reader035.vdocuments.site/reader035/viewer/2022081403/555e368ed8b42aad058b48bf/html5/thumbnails/40.jpg)
Paul Solt iPhoneDev.tv
int *address = 0;int x = 18;address = &x;*address = 27;
address x
0x1234 0x5544
0x5544 27
![Page 41: Variables and Types in Objective-C and C Programming](https://reader035.vdocuments.site/reader035/viewer/2022081403/555e368ed8b42aad058b48bf/html5/thumbnails/41.jpg)
Paul Solt iPhoneDev.tv
struct Point { int x; int y;};
...
struct Point a;a.x = 25;a.y = 100;
![Page 42: Variables and Types in Objective-C and C Programming](https://reader035.vdocuments.site/reader035/viewer/2022081403/555e368ed8b42aad058b48bf/html5/thumbnails/42.jpg)
Paul Solt iPhoneDev.tv
struct Point { int x; int y;};
...
struct Point a;a.x = 25;a.y = 100;
(25, 100)y
x
![Page 43: Variables and Types in Objective-C and C Programming](https://reader035.vdocuments.site/reader035/viewer/2022081403/555e368ed8b42aad058b48bf/html5/thumbnails/43.jpg)
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)
![Page 44: Variables and Types in Objective-C and C Programming](https://reader035.vdocuments.site/reader035/viewer/2022081403/555e368ed8b42aad058b48bf/html5/thumbnails/44.jpg)
Paul Solt iPhoneDev.tv