0% found this document useful (0 votes)
8 views107 pages

C++ 20 Arrays: Basics to Advanced

The document is a presentation on arrays in C++ 20, covering topics such as declaration, initialization, and operations on arrays. It includes sections on single and multi-dimensional arrays, array bounds, and character arrays, along with practical examples and illustrations. The content is structured to guide learners from fundamental concepts to more advanced applications of arrays.

Uploaded by

shubhgupta22229
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views107 pages

C++ 20 Arrays: Basics to Advanced

The document is a presentation on arrays in C++ 20, covering topics such as declaration, initialization, and operations on arrays. It includes sections on single and multi-dimensional arrays, array bounds, and character arrays, along with practical examples and illustrations. The content is structured to guide learners from fundamental concepts to more advanced applications of arrays.

Uploaded by

shubhgupta22229
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Slides

Section : Arrays
1
The C++ 20 Masterclass : From Fundamentals to Advanced © Daniel Gakwaya
Slide intentionally left empty

2
The C++ 20 Masterclass : From Fundamentals to Advanced © Daniel Gakwaya
Arrays : Introduction

3
The C++ 20 Masterclass : From Fundamentals to Advanced © Daniel Gakwaya
int int int int int int int int

int int int int int int int int

int int int int int int

4
The C++ 20 Masterclass : From Fundamentals to Advanced © Daniel Gakwaya
int int int int int int int int

int int int int int int int int

int int int int int int

5
The C++ 20 Masterclass : From Fundamentals to Advanced © Daniel Gakwaya
int int int int int int int int

int int int int int int int int

int int int int int int

collection_name

6
The C++ 20 Masterclass : From Fundamentals to Advanced © Daniel Gakwaya
7
The C++ 20 Masterclass : From Fundamentals to Advanced © Daniel Gakwaya
8
The C++ 20 Masterclass : From Fundamentals to Advanced © Daniel Gakwaya
9
collection_name
The C++ 20 Masterclass : From Fundamentals to Advanced © Daniel Gakwaya
Slide intentionally left empty

10
The C++ 20 Masterclass : From Fundamentals to Advanced © Daniel Gakwaya
Declaring and Using Arrays

11
The C++ 20 Masterclass : From Fundamentals to Advanced © Daniel Gakwaya
12
The C++ 20 Masterclass : From Fundamentals to Advanced © Daniel Gakwaya
scores

13
The C++ 20 Masterclass : From Fundamentals to Advanced © Daniel Gakwaya
scores

[0]
[1]
[2]
[3]
[4]
[5]
[6]
[7]
[8]
[9]

14
The C++ 20 Masterclass : From Fundamentals to Advanced © Daniel Gakwaya
Declaring and Reading from an Array

15
The C++ 20 Masterclass : From Fundamentals to Advanced © Daniel Gakwaya
[0] [1] [2] [3] [4] [5] [6] [7] [8] [9]

xx xx xx xx xx xx xx xx xx xx

16
The C++ 20 Masterclass : From Fundamentals to Advanced © Daniel Gakwaya
Array Bounds

17
The C++ 20 Masterclass : From Fundamentals to Advanced © Daniel Gakwaya
[0] [1] [2] [3] [4] [5] [6] [7] [8] [9]

xx xx xx xx xx xx xx xx xx xx xx xx

18
The C++ 20 Masterclass : From Fundamentals to Advanced © Daniel Gakwaya
Looping through an array

19
The C++ 20 Masterclass : From Fundamentals to Advanced © Daniel Gakwaya
Writing data into an array

20
The C++ 20 Masterclass : From Fundamentals to Advanced © Daniel Gakwaya
[0] [1] [2] [3] [4] [5] [6] [7] [8] [9]

xx 20 21 22 xx xx xx xx xx xx xx xx

21
The C++ 20 Masterclass : From Fundamentals to Advanced © Daniel Gakwaya
Writing data with a loop

22
The C++ 20 Masterclass : From Fundamentals to Advanced © Daniel Gakwaya
Initialize the array at declaration

23
The C++ 20 Masterclass : From Fundamentals to Advanced © Daniel Gakwaya
Array Initialization : Omitting elements

24
The C++ 20 Masterclass : From Fundamentals to Advanced © Daniel Gakwaya
Array Declaration : Omit size

25
The C++ 20 Masterclass : From Fundamentals to Advanced © Daniel Gakwaya
Constant Arrays

26
The C++ 20 Masterclass : From Fundamentals to Advanced © Daniel Gakwaya
Operations on data stored in arrays

27
The C++ 20 Masterclass : From Fundamentals to Advanced © Daniel Gakwaya
Slide intentionally left empty

28
The C++ 20 Masterclass : From Fundamentals to Advanced © Daniel Gakwaya
Size of An Array

29
The C++ 20 Masterclass : From Fundamentals to Advanced © Daniel Gakwaya
std::size() [C++17]

30
The C++ 20 Masterclass : From Fundamentals to Advanced © Daniel Gakwaya
Array size with sizeof

31
The C++ 20 Masterclass : From Fundamentals to Advanced © Daniel Gakwaya
Looping through an array

32
The C++ 20 Masterclass : From Fundamentals to Advanced © Daniel Gakwaya
Slide intentionally left empty

33
The C++ 20 Masterclass : From Fundamentals to Advanced © Daniel Gakwaya
Arrays of Characters

34
The C++ 20 Masterclass : From Fundamentals to Advanced © Daniel Gakwaya
Array of characters

35
The C++ 20 Masterclass : From Fundamentals to Advanced © Daniel Gakwaya
Direct print out

36
The C++ 20 Masterclass : From Fundamentals to Advanced © Daniel Gakwaya
Null termination

\0

37
The C++ 20 Masterclass : From Fundamentals to Advanced © Daniel Gakwaya
Proper null termination

38
The C++ 20 Masterclass : From Fundamentals to Advanced © Daniel Gakwaya
Auto filled in null characters

39
The C++ 20 Masterclass : From Fundamentals to Advanced © Daniel Gakwaya
Looks may be deceiving

40
The C++ 20 Masterclass : From Fundamentals to Advanced © Daniel Gakwaya
Literal C-strings

41
The C++ 20 Masterclass : From Fundamentals to Advanced © Daniel Gakwaya
Arrays of char are special

42
The C++ 20 Masterclass : From Fundamentals to Advanced © Daniel Gakwaya
Slide intentionally left empty

43
The C++ 20 Masterclass : From Fundamentals to Advanced © Daniel Gakwaya
Bounds of an Array

44
The C++ 20 Masterclass : From Fundamentals to Advanced © Daniel Gakwaya
45
The C++ 20 Masterclass : From Fundamentals to Advanced © Daniel Gakwaya
Array bounds

46
The C++ 20 Masterclass : From Fundamentals to Advanced © Daniel Gakwaya
Slide intentionally left empty

47
The C++ 20 Masterclass : From Fundamentals to Advanced © Daniel Gakwaya
Generating Random Numbers

48
The C++ 20 Masterclass : From Fundamentals to Advanced © Daniel Gakwaya
A lot of applications for random numbers

49
The C++ 20 Masterclass : From Fundamentals to Advanced © Daniel Gakwaya
50
The C++ 20 Masterclass : From Fundamentals to Advanced © Daniel Gakwaya
std::rand()

51
The C++ 20 Masterclass : From Fundamentals to Advanced © Daniel Gakwaya
Random ranges

52
The C++ 20 Masterclass : From Fundamentals to Advanced © Daniel Gakwaya
Random ranges

53
The C++ 20 Masterclass : From Fundamentals to Advanced © Daniel Gakwaya
std::rand Same sequence each time the program runs

54
The C++ 20 Masterclass : From Fundamentals to Advanced © Daniel Gakwaya
Seed

55
The C++ 20 Masterclass : From Fundamentals to Advanced © Daniel Gakwaya
Proper seeding

56
The C++ 20 Masterclass : From Fundamentals to Advanced © Daniel Gakwaya
Slide intentionally left empty

57
The C++ 20 Masterclass : From Fundamentals to Advanced © Daniel Gakwaya
Fortune Teller v1

58
The C++ 20 Masterclass : From Fundamentals to Advanced © Daniel Gakwaya
Fortune Teller : General Flow Control

A lot of applications for random numbers

59
The C++ 20 Masterclass : From Fundamentals to Advanced © Daniel Gakwaya
Storing the predictions

60
The C++ 20 Masterclass : From Fundamentals to Advanced © Daniel Gakwaya
Choosing the prediction randomly

61
The C++ 20 Masterclass : From Fundamentals to Advanced © Daniel Gakwaya
Slide intentionally left empty

62
The C++ 20 Masterclass : From Fundamentals to Advanced © Daniel Gakwaya
Multi Dimensional Arrays

63
The C++ 20 Masterclass : From Fundamentals to Advanced © Daniel Gakwaya
64
The C++ 20 Masterclass : From Fundamentals to Advanced © Daniel Gakwaya
65
The C++ 20 Masterclass : From Fundamentals to Advanced © Daniel Gakwaya
Declaring a 2d array and printing it out

66
The C++ 20 Masterclass : From Fundamentals to Advanced © Daniel Gakwaya
[0][0] [0][1] [0][2]

[1][0] [1][1] [1][2]

[2][0] [2][1] [2][2]

[3][0] [3][1] [3][2]

67
The C++ 20 Masterclass : From Fundamentals to Advanced © Daniel Gakwaya
xx xx xx

xx xx xx

xx xx xx

xx xx xx

68
The C++ 20 Masterclass : From Fundamentals to Advanced © Daniel Gakwaya
Printing data out

69
The C++ 20 Masterclass : From Fundamentals to Advanced © Daniel Gakwaya
Initialize multi dimensional array with data

70
The C++ 20 Masterclass : From Fundamentals to Advanced © Daniel Gakwaya
Declaring a 3d array

71
The C++ 20 Masterclass : From Fundamentals to Advanced © Daniel Gakwaya
Printing out a 3d array

72
The C++ 20 Masterclass : From Fundamentals to Advanced © Daniel Gakwaya
Omitting dimensions out

73
The C++ 20 Masterclass : From Fundamentals to Advanced © Daniel Gakwaya
Omitting dimensions out

74
The C++ 20 Masterclass : From Fundamentals to Advanced © Daniel Gakwaya
Auto filling

75
The C++ 20 Masterclass : From Fundamentals to Advanced © Daniel Gakwaya
76
The C++ 20 Masterclass : From Fundamentals to Advanced © Daniel Gakwaya
Slide intentionally left empty

77
The C++ 20 Masterclass : From Fundamentals to Advanced © Daniel Gakwaya
Multi Dimensional Arrays of
Characters

78
The C++ 20 Masterclass : From Fundamentals to Advanced © Daniel Gakwaya
‘A’ ‘l’ ‘l’

‘i’ ‘s’ ‘g’

‘o’ ‘o’ ‘d’

79
The C++ 20 Masterclass : From Fundamentals to Advanced © Daniel Gakwaya
Declaration

80
The C++ 20 Masterclass : From Fundamentals to Advanced © Daniel Gakwaya
Print out 2d array of char

81
The C++ 20 Masterclass : From Fundamentals to Advanced © Daniel Gakwaya
C-string literals

82
The C++ 20 Masterclass : From Fundamentals to Advanced © Daniel Gakwaya
Predictions : Fortune Teller V1

83
The C++ 20 Masterclass : From Fundamentals to Advanced © Daniel Gakwaya
Predictions : Fortune Teller V2

84
The C++ 20 Masterclass : From Fundamentals to Advanced © Daniel Gakwaya
Slide intentionally left empty

85
The C++ 20 Masterclass : From Fundamentals to Advanced © Daniel Gakwaya
Fortune Teller v2

86
The C++ 20 Masterclass : From Fundamentals to Advanced © Daniel Gakwaya
Fortune Teller : General Flow Control

A lot of applications for random numbers

87
The C++ 20 Masterclass : From Fundamentals to Advanced © Daniel Gakwaya
Storing the predictions

88
The C++ 20 Masterclass : From Fundamentals to Advanced © Daniel Gakwaya
Choosing the prediction randomly

89
The C++ 20 Masterclass : From Fundamentals to Advanced © Daniel Gakwaya
Updating string storage

90
The C++ 20 Masterclass : From Fundamentals to Advanced © Daniel Gakwaya
Replace entire switch with single array index access line

91
The C++ 20 Masterclass : From Fundamentals to Advanced © Daniel Gakwaya
Slide intentionally left empty

92
The C++ 20 Masterclass : From Fundamentals to Advanced © Daniel Gakwaya
Arrays : Summary

93
The C++ 20 Masterclass : From Fundamentals to Advanced © Daniel Gakwaya
int int int int int int int int

int int int int int int int int

int int int int int int

94
The C++ 20 Masterclass : From Fundamentals to Advanced © Daniel Gakwaya
int int int int int int int int

int int int int int int int int

int int int int int int

95
The C++ 20 Masterclass : From Fundamentals to Advanced © Daniel Gakwaya
int int int int int int int int

int int int int int int int int

int int int int int int

collection_name

96
The C++ 20 Masterclass : From Fundamentals to Advanced © Daniel Gakwaya
97
The C++ 20 Masterclass : From Fundamentals to Advanced © Daniel Gakwaya
98
The C++ 20 Masterclass : From Fundamentals to Advanced © Daniel Gakwaya
99
collection_name
The C++ 20 Masterclass : From Fundamentals to Advanced © Daniel Gakwaya
Declaring and Reading from an Array

100
The C++ 20 Masterclass : From Fundamentals to Advanced © Daniel Gakwaya
Initialize the array at declaration

101
The C++ 20 Masterclass : From Fundamentals to Advanced © Daniel Gakwaya
std::size() [C++17]

102
The C++ 20 Masterclass : From Fundamentals to Advanced © Daniel Gakwaya
Character arrays

103
The C++ 20 Masterclass : From Fundamentals to Advanced © Daniel Gakwaya
104
The C++ 20 Masterclass : From Fundamentals to Advanced © Daniel Gakwaya
Multidimensional arrays

105
The C++ 20 Masterclass : From Fundamentals to Advanced © Daniel Gakwaya
2D array of characters

106
The C++ 20 Masterclass : From Fundamentals to Advanced © Daniel Gakwaya
Slide intentionally left empty

107
The C++ 20 Masterclass : From Fundamentals to Advanced © Daniel Gakwaya

You might also like