





























































Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Arrays in C Programming, introduction to the topic
Typology: Slides
1 / 69
This page cannot be seen from the preview
Don't miss anything!






























































サルバド - ル・フロランテ
Visual Examples of Arrays 2 https://pixabay.com/vectors/chessboard-chess-board-game-29630/ https://en.wikipedia.org/wiki/Rubik%27s_Cube#/media/ File:Rubiks_cube_solved.jpg https://www.photos-public-domain.com/2011/08/30/truth/
Visual Examples of Arrays 4 https://pixabay.com/vectors/chessboard-chess-board-game-29630/ https://en.wikipedia.org/wiki/Rubik%27s_Cube#/media/ File:Rubiks_cube_solved.jpg https://www.photos-public-domain.com/2011/08/30/truth/ 2D array 8 rows by 8 columns = group of 64 squares
st
Visual Examples of Arrays 5 https://pixabay.com/vectors/chessboard-chess-board-game-29630/ https://en.wikipedia.org/wiki/Rubik%27s_Cube#/media/ File:Rubiks_cube_solved.jpg https://www.photos-public-domain.com/2011/08/30/truth/
st
3D array 3 (length) by 3 (width) by 3 (height) = group of 27 small cubes
Q: How do you declare an array in C?
Example: Array Declarations
char str[5]; int A[5], B[10]; float Grades[40]; double D[1000]; name : str dimensionality : 1D size : 5 element type : char
Example: Array Declarations
char str[5]; int A[5], B[10]; float Grades[40]; double D[1000];
char CrossWord[10][10]; // 10 rows x 10 columns int Sudoku[9][9]; float Table[2][4]; double Matrix[3][5];
int RubikCube[3][3][3]; name : RubikCube dimensionality : 3D size : 3x3x element type : int
Exercise: Declare array variables for the ff. https://pixabay.com/vectors/chessboard-chess-board-game-29630/ https://www.photos-public-domain.com/2011/08/30/truth/ https://en.wikipedia.org/wiki/Rubik%27s_Revenge# /media/File:Rubiks_revenge_solved.jpg https://www.goodfreephotos.com/other- photos/stack-of-flat-rocks.jpg.php
Q: How do you visualize/draw a 1D Array? Option 1: draw it vertically
Q: How do you visualize/draw a 1D Array? Option 2: or draw it horizontally
Q: How do you visualize/draw a 1D Array? Drawing an array of floating point values
Q: How do you access an array element? Declaration: int A[8];
Q: How do you access an array element? index is from 0 to size - 1 Declaration: int A[8];
Q: How do you access an array element? Access an element by giving the array name, and its index enclosed in [ ]. A[0] A[3] A[7] A[4] A[5] A[6] A[2] A[1] Declaration: int A[8];