Chapter 6 MuscularSystem. Types of Muscle SkeletalSmoothCardiac.
Chapter 6 Data Types. 2 3 4 5 6 7 8 9 10.
-
Upload
jorge-franey -
Category
Documents
-
view
234 -
download
2
Transcript of Chapter 6 Data Types. 2 3 4 5 6 7 8 9 10.
![Page 1: Chapter 6 Data Types. 2 3 4 5 6 7 8 9 10.](https://reader035.fdocuments.in/reader035/viewer/2022081506/56649c765503460f9492acd7/html5/thumbnails/1.jpg)
Chapter 6
Data Types
![Page 2: Chapter 6 Data Types. 2 3 4 5 6 7 8 9 10.](https://reader035.fdocuments.in/reader035/viewer/2022081506/56649c765503460f9492acd7/html5/thumbnails/2.jpg)
2
![Page 3: Chapter 6 Data Types. 2 3 4 5 6 7 8 9 10.](https://reader035.fdocuments.in/reader035/viewer/2022081506/56649c765503460f9492acd7/html5/thumbnails/3.jpg)
3
![Page 4: Chapter 6 Data Types. 2 3 4 5 6 7 8 9 10.](https://reader035.fdocuments.in/reader035/viewer/2022081506/56649c765503460f9492acd7/html5/thumbnails/4.jpg)
4
![Page 5: Chapter 6 Data Types. 2 3 4 5 6 7 8 9 10.](https://reader035.fdocuments.in/reader035/viewer/2022081506/56649c765503460f9492acd7/html5/thumbnails/5.jpg)
5
![Page 6: Chapter 6 Data Types. 2 3 4 5 6 7 8 9 10.](https://reader035.fdocuments.in/reader035/viewer/2022081506/56649c765503460f9492acd7/html5/thumbnails/6.jpg)
6
![Page 7: Chapter 6 Data Types. 2 3 4 5 6 7 8 9 10.](https://reader035.fdocuments.in/reader035/viewer/2022081506/56649c765503460f9492acd7/html5/thumbnails/7.jpg)
7
![Page 8: Chapter 6 Data Types. 2 3 4 5 6 7 8 9 10.](https://reader035.fdocuments.in/reader035/viewer/2022081506/56649c765503460f9492acd7/html5/thumbnails/8.jpg)
8
![Page 9: Chapter 6 Data Types. 2 3 4 5 6 7 8 9 10.](https://reader035.fdocuments.in/reader035/viewer/2022081506/56649c765503460f9492acd7/html5/thumbnails/9.jpg)
9
![Page 10: Chapter 6 Data Types. 2 3 4 5 6 7 8 9 10.](https://reader035.fdocuments.in/reader035/viewer/2022081506/56649c765503460f9492acd7/html5/thumbnails/10.jpg)
10
![Page 11: Chapter 6 Data Types. 2 3 4 5 6 7 8 9 10.](https://reader035.fdocuments.in/reader035/viewer/2022081506/56649c765503460f9492acd7/html5/thumbnails/11.jpg)
11
![Page 12: Chapter 6 Data Types. 2 3 4 5 6 7 8 9 10.](https://reader035.fdocuments.in/reader035/viewer/2022081506/56649c765503460f9492acd7/html5/thumbnails/12.jpg)
12
![Page 13: Chapter 6 Data Types. 2 3 4 5 6 7 8 9 10.](https://reader035.fdocuments.in/reader035/viewer/2022081506/56649c765503460f9492acd7/html5/thumbnails/13.jpg)
13
![Page 14: Chapter 6 Data Types. 2 3 4 5 6 7 8 9 10.](https://reader035.fdocuments.in/reader035/viewer/2022081506/56649c765503460f9492acd7/html5/thumbnails/14.jpg)
14
![Page 15: Chapter 6 Data Types. 2 3 4 5 6 7 8 9 10.](https://reader035.fdocuments.in/reader035/viewer/2022081506/56649c765503460f9492acd7/html5/thumbnails/15.jpg)
15
![Page 16: Chapter 6 Data Types. 2 3 4 5 6 7 8 9 10.](https://reader035.fdocuments.in/reader035/viewer/2022081506/56649c765503460f9492acd7/html5/thumbnails/16.jpg)
16
![Page 17: Chapter 6 Data Types. 2 3 4 5 6 7 8 9 10.](https://reader035.fdocuments.in/reader035/viewer/2022081506/56649c765503460f9492acd7/html5/thumbnails/17.jpg)
17
![Page 18: Chapter 6 Data Types. 2 3 4 5 6 7 8 9 10.](https://reader035.fdocuments.in/reader035/viewer/2022081506/56649c765503460f9492acd7/html5/thumbnails/18.jpg)
18
![Page 19: Chapter 6 Data Types. 2 3 4 5 6 7 8 9 10.](https://reader035.fdocuments.in/reader035/viewer/2022081506/56649c765503460f9492acd7/html5/thumbnails/19.jpg)
19
![Page 20: Chapter 6 Data Types. 2 3 4 5 6 7 8 9 10.](https://reader035.fdocuments.in/reader035/viewer/2022081506/56649c765503460f9492acd7/html5/thumbnails/20.jpg)
20
![Page 21: Chapter 6 Data Types. 2 3 4 5 6 7 8 9 10.](https://reader035.fdocuments.in/reader035/viewer/2022081506/56649c765503460f9492acd7/html5/thumbnails/21.jpg)
21
![Page 22: Chapter 6 Data Types. 2 3 4 5 6 7 8 9 10.](https://reader035.fdocuments.in/reader035/viewer/2022081506/56649c765503460f9492acd7/html5/thumbnails/22.jpg)
22
![Page 23: Chapter 6 Data Types. 2 3 4 5 6 7 8 9 10.](https://reader035.fdocuments.in/reader035/viewer/2022081506/56649c765503460f9492acd7/html5/thumbnails/23.jpg)
23
![Page 24: Chapter 6 Data Types. 2 3 4 5 6 7 8 9 10.](https://reader035.fdocuments.in/reader035/viewer/2022081506/56649c765503460f9492acd7/html5/thumbnails/24.jpg)
24
![Page 25: Chapter 6 Data Types. 2 3 4 5 6 7 8 9 10.](https://reader035.fdocuments.in/reader035/viewer/2022081506/56649c765503460f9492acd7/html5/thumbnails/25.jpg)
25
![Page 26: Chapter 6 Data Types. 2 3 4 5 6 7 8 9 10.](https://reader035.fdocuments.in/reader035/viewer/2022081506/56649c765503460f9492acd7/html5/thumbnails/26.jpg)
26
![Page 27: Chapter 6 Data Types. 2 3 4 5 6 7 8 9 10.](https://reader035.fdocuments.in/reader035/viewer/2022081506/56649c765503460f9492acd7/html5/thumbnails/27.jpg)
27
![Page 28: Chapter 6 Data Types. 2 3 4 5 6 7 8 9 10.](https://reader035.fdocuments.in/reader035/viewer/2022081506/56649c765503460f9492acd7/html5/thumbnails/28.jpg)
28
![Page 29: Chapter 6 Data Types. 2 3 4 5 6 7 8 9 10.](https://reader035.fdocuments.in/reader035/viewer/2022081506/56649c765503460f9492acd7/html5/thumbnails/29.jpg)
29
Pointer Type
A pointer has a memory address as it value (r-value), and also has a special value, nil (NULL in C)
Pointer operations:
•Assignment: Sets a pointer variable’s value to some useful address(&) .
•Dereferncing: Fetches the value in the memory cell whose address is referenced
by the pointer(*) .
![Page 30: Chapter 6 Data Types. 2 3 4 5 6 7 8 9 10.](https://reader035.fdocuments.in/reader035/viewer/2022081506/56649c765503460f9492acd7/html5/thumbnails/30.jpg)
30
Pointer Types (C)
#include<stdio.h;>int main{()
int k, n; int *p;//Pointer declaration
k = 560; p = &k;//Pointer assignment
n = *p;//Pointer dereferencing printf("\n n = %d ",n); //Prints 560
return(0);
}
![Page 31: Chapter 6 Data Types. 2 3 4 5 6 7 8 9 10.](https://reader035.fdocuments.in/reader035/viewer/2022081506/56649c765503460f9492acd7/html5/thumbnails/31.jpg)
31
Pointer Variables - Applications
Indirect addressing ( p=&k )
Array addressing ( *(mat+3) )
Record Field addressing ( s->id )
Allocation of dynamic storage
)p = (int*) malloc(64) ;(
![Page 32: Chapter 6 Data Types. 2 3 4 5 6 7 8 9 10.](https://reader035.fdocuments.in/reader035/viewer/2022081506/56649c765503460f9492acd7/html5/thumbnails/32.jpg)
32
Dangling Reference
•A dangling reference is a pointer that contains address of a dynamic variable that has been
deallocated .
–Pointer “p1” is set to point to a new heap-dynamic variable.
–Pointer “p2” is assigned p1’s value.–The heap dynamic variable pointed to by “p1” is
explicitly deallocated , and p1 is set to null. Pointer p2 is not changed. p2 is now a dangling reference.
![Page 33: Chapter 6 Data Types. 2 3 4 5 6 7 8 9 10.](https://reader035.fdocuments.in/reader035/viewer/2022081506/56649c765503460f9492acd7/html5/thumbnails/33.jpg)
33
Dangling Reference
Heap
p1
p2
Heap
p1 (NULL)
p2
(Deallocated)
![Page 34: Chapter 6 Data Types. 2 3 4 5 6 7 8 9 10.](https://reader035.fdocuments.in/reader035/viewer/2022081506/56649c765503460f9492acd7/html5/thumbnails/34.jpg)
34
Dangling Reference
ProblemsThe location being pointed to by p2 may have been reallocated to some new heap-dynamic
variable .
The new value will bear no relationship with the old pointer’s dereferenced value .
If p2 is used to change the heap dynamic variable, then the value of the new heap dynamic variable will be destroyed.
![Page 35: Chapter 6 Data Types. 2 3 4 5 6 7 8 9 10.](https://reader035.fdocuments.in/reader035/viewer/2022081506/56649c765503460f9492acd7/html5/thumbnails/35.jpg)
35
Lost ObjectA lost heap-dynamic variable (lost object) is an allocated heap-dynamic variable that is no longer accessible to the user program, but still contains some useful data.
Pointer p1 is set to point to a heap-dynamic variable.
p1 is set to point to another heap dynamic variable. The first heap-dynamic variable is now inaccessible, or lost.
![Page 36: Chapter 6 Data Types. 2 3 4 5 6 7 8 9 10.](https://reader035.fdocuments.in/reader035/viewer/2022081506/56649c765503460f9492acd7/html5/thumbnails/36.jpg)
36
Lost Object
Heap
p1
Heap
p1
Heap
Lost object
![Page 37: Chapter 6 Data Types. 2 3 4 5 6 7 8 9 10.](https://reader035.fdocuments.in/reader035/viewer/2022081506/56649c765503460f9492acd7/html5/thumbnails/37.jpg)
37
Pointers and Java
•Java does not provide indirect addressing (&) and dereferencing
operators .(*)
•Java also does not allow any pointer arithmetic .
•Java does not allow explicit deallocation of storage. There is no explicit deallocation operator (such as “delete”).
Since storage cannot be explicitly deallocated, you cannot have a dangling reference in Java.
![Page 38: Chapter 6 Data Types. 2 3 4 5 6 7 8 9 10.](https://reader035.fdocuments.in/reader035/viewer/2022081506/56649c765503460f9492acd7/html5/thumbnails/38.jpg)
38
Heap Management
•Never reassign a pointer variable which has a dynamic storage allocation. Before reassigning a pointer, make sure that the storage it points to, is deallocated.
•Immediately after deallocating a heap-dynamic storage, reset to null all the pointer variables pointing to it.
•Whenever a large storage allocation from heap is requested, check if enough memory is available.