Sie sind auf Seite 1von 96

Programming in C

Arrays

Copyright BlueSignet LLC. All rights reserved. For more visit WiBit.Net

One Dimensional Array: Review


List of common elements

Copyright BlueSignet LLC. All rights reserved. For more visit WiBit.Net

Programming in C

One Dimensional Array: Review


List of common elements

Example: Character Array of Size 5

char[]

Copyright BlueSignet LLC. All rights reserved. For more visit WiBit.Net

Programming in C

One Dimensional Array: Review


List of common elements

Example: Character Array of Size 5

char[]

Copyright BlueSignet LLC. All rights reserved. For more visit WiBit.Net

t
Programming in C

One Dimensional Array: Template


<Variable Type> <Variable Name>[<Size>];

Copyright BlueSignet LLC. All rights reserved. For more visit WiBit.Net

Programming in C

One Dimensional Array: Template


<Variable Type> <Variable Name>[<Size>];

char websiteName[5];

Copyright BlueSignet LLC. All rights reserved. For more visit WiBit.Net

Programming in C

One Dimensional Array: Template


<Variable Type> <Variable Name>[<Size>];

char websiteName[5];

Copyright BlueSignet LLC. All rights reserved. For more visit WiBit.Net

Programming in C

One Dimensional Array: Template


<Variable Type> <Variable Name>[<Size>];

char websiteName[5];

Copyright BlueSignet LLC. All rights reserved. For more visit WiBit.Net

Programming in C

One Dimensional Array: Template


<Variable Type> <Variable Name>[<Size>];

char websiteName[5];

Copyright BlueSignet LLC. All rights reserved. For more visit WiBit.Net

Programming in C

One Dimensional Array: How to value

char websiteName[5];
char websiteName[]

Copyright BlueSignet LLC. All rights reserved. For more visit WiBit.Net

Programming in C

One Dimensional Array: How to value

char websiteName[5];
websiteName[0] = W;

char websiteName[]

Copyright BlueSignet LLC. All rights reserved. For more visit WiBit.Net

Programming in C

One Dimensional Array: How to value

char websiteName[5];
websiteName[0] = W;
websiteName[1] = i;

Copyright BlueSignet LLC. All rights reserved. For more visit WiBit.Net

char websiteName[]

Programming in C

One Dimensional Array: How to value

char websiteName[5];
websiteName[0] = W;
websiteName[1] = i;
websiteName[2] = B;

Copyright BlueSignet LLC. All rights reserved. For more visit WiBit.Net

char websiteName[]

Programming in C

One Dimensional Array: How to value

char websiteName[5];
websiteName[0] = W;
websiteName[1] = i;
websiteName[2] = B;
websiteName[3] = i;

Copyright BlueSignet LLC. All rights reserved. For more visit WiBit.Net

char websiteName[]

Programming in C

One Dimensional Array: How to value

char websiteName[5];
websiteName[0] = W;
websiteName[1] = i;
websiteName[2] = B;
websiteName[3] = i;
websiteName[4] = t;

Copyright BlueSignet LLC. All rights reserved. For more visit WiBit.Net

char websiteName[]

Programming in C

Two Dimensional Array: Review


Grid View list of common elements

Copyright BlueSignet LLC. All rights reserved. For more visit WiBit.Net

Programming in C

Two Dimensional Array: Review


Grid View list of common elements

int[][]
0
1

0
1
Copyright BlueSignet LLC. All rights reserved. For more visit WiBit.Net

Programming in C

Two Dimensional Array: Review


Grid View list of common elements

Row
Indexes

int[][]
0
1

Column
Indexes

Copyright BlueSignet LLC. All rights reserved. For more visit WiBit.Net

Values

Programming in C

Two Dimensional Array: Review


Can be viewed as a single dimensional array with

another single dimensional array in each element

Copyright BlueSignet LLC. All rights reserved. For more visit WiBit.Net

Programming in C

Two Dimensional Array: Review


Can be viewed as a single dimensional array with

another single dimensional array in each element

char[]

Copyright BlueSignet LLC. All rights reserved. For more visit WiBit.Net

Programming in C

Two Dimensional Array: Review


Can be viewed as a single dimensional array with

another single dimensional array in each element

char[]

Copyright BlueSignet LLC. All rights reserved. For more visit WiBit.Net

Programming in C

Two Dimensional Array: Review


Can be viewed as a single dimensional array with

another single dimensional array in each element

char[]

Copyright BlueSignet LLC. All rights reserved. For more visit WiBit.Net

Programming in C

Two Dimensional Array: Template


<Variable Type> <Variable Name>[<#Rows>] [<#Columns>];

int additionTable[2][5];

Copyright BlueSignet LLC. All rights reserved. For more visit WiBit.Net

Programming in C

Two Dimensional Array: How to value


int additionTable[2][5];
// Row 0

0123 4
0
1

Copyright BlueSignet LLC. All rights reserved. For more visit WiBit.Net

Programming in C

Two Dimensional Array: How to value


int additionTable[2][5];
// Row 0
additionTable[0][0] = 0;

0123 4
00
1

Copyright BlueSignet LLC. All rights reserved. For more visit WiBit.Net

Programming in C

Two Dimensional Array: How to value


int additionTable[2][5];
// Row 0
additionTable[0][0] = 0;
additionTable[0][1] = 1;

0123 4
001
1

Copyright BlueSignet LLC. All rights reserved. For more visit WiBit.Net

Programming in C

Two Dimensional Array: How to value


int additionTable[2][5];
// Row 0
additionTable[0][0] = 0;
additionTable[0][1] = 1;
additionTable[0][2] = 2;

0123 4
0012
1

Copyright BlueSignet LLC. All rights reserved. For more visit WiBit.Net

Programming in C

Two Dimensional Array: How to value


int additionTable[2][5];
// Row 0
additionTable[0][0] = 0;
additionTable[0][1] = 1;
additionTable[0][2] = 2;
additionTable[0][3] = 3;

0123 4
00123
1

Copyright BlueSignet LLC. All rights reserved. For more visit WiBit.Net

Programming in C

Two Dimensional Array: How to value


int additionTable[2][5];
// Row 0
additionTable[0][0] = 0;
additionTable[0][1] = 1;
additionTable[0][2] = 2;
additionTable[0][3] = 3;
additionTable[0][4] = 4;

0123 4
00123 4
1

Copyright BlueSignet LLC. All rights reserved. For more visit WiBit.Net

Programming in C

Two Dimensional Array: How to value


int additionTable[2][5];
// Row 0
additionTable[0][0] = 0;
additionTable[0][1] = 1;
additionTable[0][2] = 2;
additionTable[0][3] = 3;
additionTable[0][4] = 4;
// Row 1
additionTable[1][0] = 1;

Copyright BlueSignet LLC. All rights reserved. For more visit WiBit.Net

0123 4
00123 4
11

Programming in C

Two Dimensional Array: How to value


int additionTable[2][5];
// Row 0
additionTable[0][0] = 0;
additionTable[0][1] = 1;
additionTable[0][2] = 2;
additionTable[0][3] = 3;
additionTable[0][4] = 4;
// Row 1
additionTable[1][0] = 1;
additionTable[1][1] = 2;

Copyright BlueSignet LLC. All rights reserved. For more visit WiBit.Net

0123 4
00123 4
112

Programming in C

Two Dimensional Array: How to value


int additionTable[2][5];
// Row 0
additionTable[0][0] = 0;
additionTable[0][1] = 1;
additionTable[0][2] = 2;
additionTable[0][3] = 3;
additionTable[0][4] = 4;
// Row 1
additionTable[1][0] = 1;
additionTable[1][1] = 2;
additionTable[1][2] = 3;

Copyright BlueSignet LLC. All rights reserved. For more visit WiBit.Net

0123 4
00123 4
1123

Programming in C

Two Dimensional Array: How to value


int additionTable[2][5];
// Row 0
additionTable[0][0] = 0;
additionTable[0][1] = 1;
additionTable[0][2] = 2;
additionTable[0][3] = 3;
additionTable[0][4] = 4;
// Row 1
additionTable[1][0] = 1;
additionTable[1][1] = 2;
additionTable[1][2] = 3;
additionTable[1][3] = 4;

Copyright BlueSignet LLC. All rights reserved. For more visit WiBit.Net

0123 4
00123 4
11234

Programming in C

Two Dimensional Array: How to value


int additionTable[2][5];
// Row 0
additionTable[0][0] = 0;
additionTable[0][1] = 1;
additionTable[0][2] = 2;
additionTable[0][3] = 3;
additionTable[0][4] = 4;
// Row 1
additionTable[1][0] = 1;
additionTable[1][1] = 2;
additionTable[1][2] = 3;
additionTable[1][3] = 4;
additionTable[1][4] = 5;

Copyright BlueSignet LLC. All rights reserved. For more visit WiBit.Net

0123 4
00123 4
11234 5

Programming in C

Two Dimensional Arrays: Using Loops


const int rows = 2, cols = 5;
int additionTable[rows][cols];
// Load Array
for(int i = 0; i < rows; i++)
{
for(int j = 0; j < cols; j++)
{
additionTable[i][j] = i + j;
}
}
//Print Array
for(int i = 0; i < rows; i++)
{
for(int j = 0; j < cols; j++)
{
printf("%d\t", additionTable[i][j]);
}
putchar('\n');
}

Copyright BlueSignet LLC. All rights reserved. For more visit WiBit.Net

Programming in C

Two Dimensional Arrays: Using Loops


const int rows = 2, cols = 5;
int additionTable[rows][cols];
// Load Array
for(int i = 0; i < rows; i++)
{
for(int j = 0; j < cols; j++)
{
additionTable[i][j] = i + j;
}
}
//Print Array
for(int i = 0; i < rows; i++)
{
for(int j = 0; j < cols; j++)
{
printf("%d\t", additionTable[i][j]);
}
putchar('\n');
}

Copyright BlueSignet LLC. All rights reserved. For more visit WiBit.Net

rows
2
cols
5

Programming in C

Two Dimensional Arrays: Using Loops


const int rows = 2, cols = 5;
int additionTable[rows][cols];
// Load Array
for(int i = 0; i < rows; i++)
{
for(int j = 0; j < cols; j++)
{
additionTable[i][j] = i + j;
}
}
//Print Array
for(int i = 0; i < rows; i++)
{
for(int j = 0; j < cols; j++)
{
printf("%d\t", additionTable[i][j]);
}
putchar('\n');
}

Copyright BlueSignet LLC. All rights reserved. For more visit WiBit.Net

rows
2
additionTable

cols
5

0 1 2 3

0
1

Programming in C

Two Dimensional Arrays: Using Loops


const int rows = 2, cols = 5;
int additionTable[rows][cols];
// Load Array
for(int i = 0; i < rows; i++)
{
for(int j = 0; j < cols; j++)
{
additionTable[i][j] = i + j;
}
}
//Print Array
for(int i = 0; i < rows; i++)
{
for(int j = 0; j < cols; j++)
{
printf("%d\t", additionTable[i][j]);
}
putchar('\n');
}

Copyright BlueSignet LLC. All rights reserved. For more visit WiBit.Net

i
0

rows
2
additionTable

cols
5

0 1 2 3

0
1

Programming in C

Two Dimensional Arrays: Using Loops


const int rows = 2, cols = 5;
int additionTable[rows][cols];
// Load Array
for(int i = 0; i < rows; i++)
{
for(int j = 0; j < cols; j++)
{
additionTable[i][j] = i + j;
}
}
//Print Array
for(int i = 0; i < rows; i++)
{
for(int j = 0; j < cols; j++)
{
printf("%d\t", additionTable[i][j]);
}
putchar('\n');
}

Copyright BlueSignet LLC. All rights reserved. For more visit WiBit.Net

i
0

rows
2

j
0

additionTable

cols
5

0 1 2 3

0
1

Programming in C

Two Dimensional Arrays: Using Loops


const int rows = 2, cols = 5;
int additionTable[rows][cols];
// Load Array
for(int i = 0; i < rows; i++)
{
for(int j = 0; j < cols; j++)
{
additionTable[i][j] = i + j;
}
}
//Print Array
for(int i = 0; i < rows; i++)
{
for(int j = 0; j < cols; j++)
{
printf("%d\t", additionTable[i][j]);
}
putchar('\n');
}

Copyright BlueSignet LLC. All rights reserved. For more visit WiBit.Net

i
0

rows
2

j
0

additionTable

cols
5

0 1 2 3

0 0
1

Programming in C

Two Dimensional Arrays: Using Loops


const int rows = 2, cols = 5;
int additionTable[rows][cols];
// Load Array
for(int i = 0; i < rows; i++)
{
for(int j = 0; j < cols; j++)
{
additionTable[i][j] = i + j;
}
}
//Print Array
for(int i = 0; i < rows; i++)
{
for(int j = 0; j < cols; j++)
{
printf("%d\t", additionTable[i][j]);
}
putchar('\n');
}

Copyright BlueSignet LLC. All rights reserved. For more visit WiBit.Net

i
0

rows
2

j
1

additionTable

cols
5

0 1 2 3

0 0
1

Programming in C

Two Dimensional Arrays: Using Loops


const int rows = 2, cols = 5;
int additionTable[rows][cols];
// Load Array
for(int i = 0; i < rows; i++)
{
for(int j = 0; j < cols; j++)
{
additionTable[i][j] = i + j;
}
}
//Print Array
for(int i = 0; i < rows; i++)
{
for(int j = 0; j < cols; j++)
{
printf("%d\t", additionTable[i][j]);
}
putchar('\n');
}

Copyright BlueSignet LLC. All rights reserved. For more visit WiBit.Net

i
0

rows
2

j
1

additionTable

cols
5

0 1 2 3

0 0 1
1

Programming in C

Two Dimensional Arrays: Using Loops


const int rows = 2, cols = 5;
int additionTable[rows][cols];
// Load Array
for(int i = 0; i < rows; i++)
{
for(int j = 0; j < cols; j++)
{
additionTable[i][j] = i + j;
}
}
//Print Array
for(int i = 0; i < rows; i++)
{
for(int j = 0; j < cols; j++)
{
printf("%d\t", additionTable[i][j]);
}
putchar('\n');
}

Copyright BlueSignet LLC. All rights reserved. For more visit WiBit.Net

i
0

rows
2

j
2

additionTable

cols
5

0 1 2 3

0 0 1
1

Programming in C

Two Dimensional Arrays: Using Loops


const int rows = 2, cols = 5;
int additionTable[rows][cols];
// Load Array
for(int i = 0; i < rows; i++)
{
for(int j = 0; j < cols; j++)
{
additionTable[i][j] = i + j;
}
}
//Print Array
for(int i = 0; i < rows; i++)
{
for(int j = 0; j < cols; j++)
{
printf("%d\t", additionTable[i][j]);
}
putchar('\n');
}

Copyright BlueSignet LLC. All rights reserved. For more visit WiBit.Net

i
0

rows
2

j
2

additionTable

cols
5

0 1 2 3

0 0 1 2
1

Programming in C

Two Dimensional Arrays: Using Loops


const int rows = 2, cols = 5;
int additionTable[rows][cols];
// Load Array
for(int i = 0; i < rows; i++)
{
for(int j = 0; j < cols; j++)
{
additionTable[i][j] = i + j;
}
}
//Print Array
for(int i = 0; i < rows; i++)
{
for(int j = 0; j < cols; j++)
{
printf("%d\t", additionTable[i][j]);
}
putchar('\n');
}

Copyright BlueSignet LLC. All rights reserved. For more visit WiBit.Net

i
0

rows
2

J
3

additionTable

cols
5

0 1 2 3

0 0 1 2
1

Programming in C

Two Dimensional Arrays: Using Loops


const int rows = 2, cols = 5;
int additionTable[rows][cols];
// Load Array
for(int i = 0; i < rows; i++)
{
for(int j = 0; j < cols; j++)
{
additionTable[i][j] = i + j;
}
}
//Print Array
for(int i = 0; i < rows; i++)
{
for(int j = 0; j < cols; j++)
{
printf("%d\t", additionTable[i][j]);
}
putchar('\n');
}

Copyright BlueSignet LLC. All rights reserved. For more visit WiBit.Net

i
0

rows
2

j
3

additionTable

cols
5

0 1 2 3

0 0 1 2 3
1

Programming in C

Two Dimensional Arrays: Using Loops


const int rows = 2, cols = 5;
int additionTable[rows][cols];
// Load Array
for(int i = 0; i < rows; i++)
{
for(int j = 0; j < cols; j++)
{
additionTable[i][j] = i + j;
}
}
//Print Array
for(int i = 0; i < rows; i++)
{
for(int j = 0; j < cols; j++)
{
printf("%d\t", additionTable[i][j]);
}
putchar('\n');
}

Copyright BlueSignet LLC. All rights reserved. For more visit WiBit.Net

i
0

rows
2

j
4

additionTable

cols
5

0 1 2 3

0 0 1 2 3
1

Programming in C

Two Dimensional Arrays: Using Loops


const int rows = 2, cols = 5;
int additionTable[rows][cols];
// Load Array
for(int i = 0; i < rows; i++)
{
for(int j = 0; j < cols; j++)
{
additionTable[i][j] = i + j;
}
}
//Print Array
for(int i = 0; i < rows; i++)
{
for(int j = 0; j < cols; j++)
{
printf("%d\t", additionTable[i][j]);
}
putchar('\n');
}

Copyright BlueSignet LLC. All rights reserved. For more visit WiBit.Net

i
0

rows
2

j
4

additionTable

cols
5

0 1 2 3

0 0 1 2 3

Programming in C

Two Dimensional Arrays: Using Loops


const int rows = 2, cols = 5;
int additionTable[rows][cols];
// Load Array
for(int i = 0; i < rows; i++)
{
for(int j = 0; j < cols; j++)
{
additionTable[i][j] = i + j;
}
}
//Print Array
for(int i = 0; i < rows; i++)
{
for(int j = 0; j < cols; j++)
{
printf("%d\t", additionTable[i][j]);
}
putchar('\n');
}

Copyright BlueSignet LLC. All rights reserved. For more visit WiBit.Net

i
1

rows
2

j
4

additionTable

cols
5

0 1 2 3

0 0 1 2 3

Programming in C

Two Dimensional Arrays: Using Loops


const int rows = 2, cols = 5;
int additionTable[rows][cols];
// Load Array
for(int i = 0; i < rows; i++)
{
for(int j = 0; j < cols; j++)
{
additionTable[i][j] = i + j;
}
}
//Print Array
for(int i = 0; i < rows; i++)
{
for(int j = 0; j < cols; j++)
{
printf("%d\t", additionTable[i][j]);
}
putchar('\n');
}

Copyright BlueSignet LLC. All rights reserved. For more visit WiBit.Net

i
1

rows
2

j
0

additionTable

cols
5

0 1 2 3

0 0 1 2 3

Programming in C

Two Dimensional Arrays: Using Loops


const int rows = 2, cols = 5;
int additionTable[rows][cols];
// Load Array
for(int i = 0; i < rows; i++)
{
for(int j = 0; j < cols; j++)
{
additionTable[i][j] = i + j;
}
}
//Print Array
for(int i = 0; i < rows; i++)
{
for(int j = 0; j < cols; j++)
{
printf("%d\t", additionTable[i][j]);
}
putchar('\n');
}

Copyright BlueSignet LLC. All rights reserved. For more visit WiBit.Net

i
1

rows
2

j
0

additionTable

cols
5

0 1 2 3

0 0 1 2 3

1 1

Programming in C

Two Dimensional Arrays: Using Loops


const int rows = 2, cols = 5;
int additionTable[rows][cols];
// Load Array
for(int i = 0; i < rows; i++)
{
for(int j = 0; j < cols; j++)
{
additionTable[i][j] = i + j;
}
}
//Print Array
for(int i = 0; i < rows; i++)
{
for(int j = 0; j < cols; j++)
{
printf("%d\t", additionTable[i][j]);
}
putchar('\n');
}

Copyright BlueSignet LLC. All rights reserved. For more visit WiBit.Net

i
1

rows
2

j
1

additionTable

cols
5

0 1 2 3

0 0 1 2 3

1 1

Programming in C

Two Dimensional Arrays: Using Loops


const int rows = 2, cols = 5;
int additionTable[rows][cols];
// Load Array
for(int i = 0; i < rows; i++)
{
for(int j = 0; j < cols; j++)
{
additionTable[i][j] = i + j;
}
}
//Print Array
for(int i = 0; i < rows; i++)
{
for(int j = 0; j < cols; j++)
{
printf("%d\t", additionTable[i][j]);
}
putchar('\n');
}

Copyright BlueSignet LLC. All rights reserved. For more visit WiBit.Net

i
1

rows
2

j
1

additionTable

cols
5

0 1 2 3

0 0 1 2 3

1 1 2

Programming in C

Two Dimensional Arrays: Using Loops


const int rows = 2, cols = 5;
int additionTable[rows][cols];
// Load Array
for(int i = 0; i < rows; i++)
{
for(int j = 0; j < cols; j++)
{
additionTable[i][j] = i + j;
}
}
//Print Array
for(int i = 0; i < rows; i++)
{
for(int j = 0; j < cols; j++)
{
printf("%d\t", additionTable[i][j]);
}
putchar('\n');
}

Copyright BlueSignet LLC. All rights reserved. For more visit WiBit.Net

i
1

rows
2

j
2

additionTable

cols
5

0 1 2 3

0 0 1 2 3

1 1 2

Programming in C

Two Dimensional Arrays: Using Loops


const int rows = 2, cols = 5;
int additionTable[rows][cols];
// Load Array
for(int i = 0; i < rows; i++)
{
for(int j = 0; j < cols; j++)
{
additionTable[i][j] = i + j;
}
}
//Print Array
for(int i = 0; i < rows; i++)
{
for(int j = 0; j < cols; j++)
{
printf("%d\t", additionTable[i][j]);
}
putchar('\n');
}

Copyright BlueSignet LLC. All rights reserved. For more visit WiBit.Net

i
1

rows
2

j
2

additionTable

cols
5

0 1 2 3

0 0 1 2 3

1 1 2 3

Programming in C

Two Dimensional Arrays: Using Loops


const int rows = 2, cols = 5;
int additionTable[rows][cols];
// Load Array
for(int i = 0; i < rows; i++)
{
for(int j = 0; j < cols; j++)
{
additionTable[i][j] = i + j;
}
}
//Print Array
for(int i = 0; i < rows; i++)
{
for(int j = 0; j < cols; j++)
{
printf("%d\t", additionTable[i][j]);
}
putchar('\n');
}

Copyright BlueSignet LLC. All rights reserved. For more visit WiBit.Net

i
1

rows
2

j
3

additionTable

cols
5

0 1 2 3

0 0 1 2 3

1 1 2 3

Programming in C

Two Dimensional Arrays: Using Loops


const int rows = 2, cols = 5;
int additionTable[rows][cols];
// Load Array
for(int i = 0; i < rows; i++)
{
for(int j = 0; j < cols; j++)
{
additionTable[i][j] = i + j;
}
}
//Print Array
for(int i = 0; i < rows; i++)
{
for(int j = 0; j < cols; j++)
{
printf("%d\t", additionTable[i][j]);
}
putchar('\n');
}

Copyright BlueSignet LLC. All rights reserved. For more visit WiBit.Net

i
1

rows
2

j
3

additionTable

cols
5

0 1 2 3

0 0 1 2 3

1 1 2 3 4

Programming in C

Two Dimensional Arrays: Using Loops


const int rows = 2, cols = 5;
int additionTable[rows][cols];
// Load Array
for(int i = 0; i < rows; i++)
{
for(int j = 0; j < cols; j++)
{
additionTable[i][j] = i + j;
}
}
//Print Array
for(int i = 0; i < rows; i++)
{
for(int j = 0; j < cols; j++)
{
printf("%d\t", additionTable[i][j]);
}
putchar('\n');
}

Copyright BlueSignet LLC. All rights reserved. For more visit WiBit.Net

i
1

rows
2

j
4

additionTable

cols
5

0 1 2 3

0 0 1 2 3

1 1 2 3 4

Programming in C

Two Dimensional Arrays: Using Loops


const int rows = 2, cols = 5;
int additionTable[rows][cols];
// Load Array
for(int i = 0; i < rows; i++)
{
for(int j = 0; j < cols; j++)
{
additionTable[i][j] = i + j;
}
}
//Print Array
for(int i = 0; i < rows; i++)
{
for(int j = 0; j < cols; j++)
{
printf("%d\t", additionTable[i][j]);
}
putchar('\n');
}

Copyright BlueSignet LLC. All rights reserved. For more visit WiBit.Net

i
1

rows
2

j
4

additionTable

cols
5

0 1 2 3

0 0 1 2 3

1 1 2 3 4

Programming in C

Two Dimensional Arrays: Using Loops


const int rows = 2, cols = 5;
int additionTable[rows][cols];
// Load Array
for(int i = 0; i < rows; i++)
{
for(int j = 0; j < cols; j++)
{
additionTable[i][j] = i + j;
}
}
//Print Array
for(int i = 0; i < rows; i++)
{
for(int j = 0; j < cols; j++)
{
printf("%d\t", additionTable[i][j]);
}
putchar('\n');
}

Copyright BlueSignet LLC. All rights reserved. For more visit WiBit.Net

i
1

rows
2

j
5

additionTable

cols
5

0 1 2 3

0 0 1 2 3

1 1 2 3 4

Programming in C

Two Dimensional Arrays: Using Loops


const int rows = 2, cols = 5;
int additionTable[rows][cols];
// Load Array
for(int i = 0; i < rows; i++)
{
for(int j = 0; j < cols; j++)
{
additionTable[i][j] = i + j;
}
}
//Print Array
for(int i = 0; i < rows; i++)
{
for(int j = 0; j < cols; j++)
{
printf("%d\t", additionTable[i][j]);
}
putchar('\n');
}

Copyright BlueSignet LLC. All rights reserved. For more visit WiBit.Net

i
2

rows
2

j
5

additionTable

cols
5

0 1 2 3

0 0 1 2 3

1 1 2 3 4

Programming in C

Two Dimensional Arrays: Using Loops


const int rows = 2, cols = 5;
int additionTable[rows][cols];
// Load Array
for(int i = 0; i < rows; i++)
{
for(int j = 0; j < cols; j++)
{
additionTable[i][j] = i + j;
}
}
//Print Array
for(int i = 0; i < rows; i++)
{
for(int j = 0; j < cols; j++)
{
printf("%d\t", additionTable[i][j]);
}
putchar('\n');
}

Copyright BlueSignet LLC. All rights reserved. For more visit WiBit.Net

i
0

rows
2

j
5

additionTable

cols
5

0 1 2 3

0 0 1 2 3

1 1 2 3 4

Programming in C

Two Dimensional Arrays: Using Loops


const int rows = 2, cols = 5;
int additionTable[rows][cols];
// Load Array
for(int i = 0; i < rows; i++)
{
for(int j = 0; j < cols; j++)
{
additionTable[i][j] = i + j;
}
}
//Print Array
for(int i = 0; i < rows; i++)
{
for(int j = 0; j < cols; j++)
{
printf("%d\t", additionTable[i][j]);
}
putchar('\n');
}

Copyright BlueSignet LLC. All rights reserved. For more visit WiBit.Net

i
0

rows
2

j
0

additionTable

cols
5

0 1 2 3

0 0 1 2 3

1 1 2 3 4

Programming in C

Two Dimensional Arrays: Using Loops


const int rows = 2, cols = 5;
int additionTable[rows][cols];
// Load Array
for(int i = 0; i < rows; i++)
{
for(int j = 0; j < cols; j++)
{
additionTable[i][j] = i + j;
}
}
//Print Array
for(int i = 0; i < rows; i++)
{
for(int j = 0; j < cols; j++)
{
printf("%d\t", additionTable[i][j]);
}
putchar('\n');
}

Copyright BlueSignet LLC. All rights reserved. For more visit WiBit.Net

i
0

rows
2

j
0

additionTable

cols
5

0 1 2 3

0 0 1 2 3

1 1 2 3 4

Programming in C

Two Dimensional Arrays: Using Loops


const int rows = 2, cols = 5;
int additionTable[rows][cols];
// Load Array
for(int i = 0; i < rows; i++)
{
for(int j = 0; j < cols; j++)
{
additionTable[i][j] = i + j;
}
}
//Print Array
for(int i = 0; i < rows; i++)
{
for(int j = 0; j < cols; j++)
{
printf("%d\t", additionTable[i][j]);
}
putchar('\n');
}

Copyright BlueSignet LLC. All rights reserved. For more visit WiBit.Net

i
0

rows
2

j
1

additionTable

cols
5

0 1 2 3

0 0 1 2 3

1 1 2 3 4

Programming in C

Two Dimensional Arrays: Using Loops


const int rows = 2, cols = 5;
int additionTable[rows][cols];
// Load Array
for(int i = 0; i < rows; i++)
{
for(int j = 0; j < cols; j++)
{
additionTable[i][j] = i + j;
}
}
//Print Array
for(int i = 0; i < rows; i++)
{
for(int j = 0; j < cols; j++)
{
printf("%d\t", additionTable[i][j]);
}
putchar('\n');
}

Copyright BlueSignet LLC. All rights reserved. For more visit WiBit.Net

i
0

rows
2

j
1

additionTable

cols
5

0 1 2 3

0 0 1 2 3

1 1 2 3 4

Programming in C

Two Dimensional Arrays: Using Loops


const int rows = 2, cols = 5;
int additionTable[rows][cols];
// Load Array
for(int i = 0; i < rows; i++)
{
for(int j = 0; j < cols; j++)
{
additionTable[i][j] = i + j;
}
}
//Print Array
for(int i = 0; i < rows; i++)
{
for(int j = 0; j < cols; j++)
{
printf("%d\t", additionTable[i][j]);
}
putchar('\n');
}

Copyright BlueSignet LLC. All rights reserved. For more visit WiBit.Net

i
0

rows
2

j
2

additionTable

cols
5

0 1 2 3

0 0 1 2 3

1 1 2 3 4

Programming in C

Two Dimensional Arrays: Using Loops


const int rows = 2, cols = 5;
int additionTable[rows][cols];
// Load Array
for(int i = 0; i < rows; i++)
{
for(int j = 0; j < cols; j++)
{
additionTable[i][j] = i + j;
}
}
//Print Array
for(int i = 0; i < rows; i++)
{
for(int j = 0; j < cols; j++)
{
printf("%d\t", additionTable[i][j]);
}
putchar('\n');
}

Copyright BlueSignet LLC. All rights reserved. For more visit WiBit.Net

i
0

rows
2

j
2

additionTable

cols
5

0 1 2 3

0 0 1 2 3

1 1 2 3 4

Programming in C

Two Dimensional Arrays: Using Loops


const int rows = 2, cols = 5;
int additionTable[rows][cols];
// Load Array
for(int i = 0; i < rows; i++)
{
for(int j = 0; j < cols; j++)
{
additionTable[i][j] = i + j;
}
}
//Print Array
for(int i = 0; i < rows; i++)
{
for(int j = 0; j < cols; j++)
{
printf("%d\t", additionTable[i][j]);
}
putchar('\n');
}

Copyright BlueSignet LLC. All rights reserved. For more visit WiBit.Net

i
0

rows
2

j
3

additionTable

cols
5

0 1 2 3

0 0 1 2 3

1 1 2 3 4

Programming in C

Two Dimensional Arrays: Using Loops


const int rows = 2, cols = 5;
int additionTable[rows][cols];
// Load Array
for(int i = 0; i < rows; i++)
{
for(int j = 0; j < cols; j++)
{
additionTable[i][j] = i + j;
}
}
//Print Array
for(int i = 0; i < rows; i++)
{
for(int j = 0; j < cols; j++)
{
printf("%d\t", additionTable[i][j]);
}
putchar('\n');
}

Copyright BlueSignet LLC. All rights reserved. For more visit WiBit.Net

i
0

rows
2

j
3

additionTable

cols
5

0 1 2 3

0 0 1 2 3

1 1 2 3 4

Programming in C

Two Dimensional Arrays: Using Loops


const int rows = 2, cols = 5;
int additionTable[rows][cols];
// Load Array
for(int i = 0; i < rows; i++)
{
for(int j = 0; j < cols; j++)
{
additionTable[i][j] = i + j;
}
}
//Print Array
for(int i = 0; i < rows; i++)
{
for(int j = 0; j < cols; j++)
{
printf("%d\t", additionTable[i][j]);
}
putchar('\n');
}

Copyright BlueSignet LLC. All rights reserved. For more visit WiBit.Net

i
0

rows
2

j
4

additionTable

cols
5

0 1 2 3

0 0 1 2 3

1 1 2 3 4

Programming in C

Two Dimensional Arrays: Using Loops


const int rows = 2, cols = 5;
int additionTable[rows][cols];
// Load Array
for(int i = 0; i < rows; i++)
{
for(int j = 0; j < cols; j++)
{
additionTable[i][j] = i + j;
}
}
//Print Array
for(int i = 0; i < rows; i++)
{
for(int j = 0; j < cols; j++)
{
printf("%d\t", additionTable[i][j]);
}
putchar('\n');
}

Copyright BlueSignet LLC. All rights reserved. For more visit WiBit.Net

i
0

rows
2

j
4

additionTable

cols
5

0 1 2 3

0 0 1 2 3

1 1 2 3 4

Programming in C

Two Dimensional Arrays: Using Loops


const int rows = 2, cols = 5;
int additionTable[rows][cols];
// Load Array
for(int i = 0; i < rows; i++)
{
for(int j = 0; j < cols; j++)
{
additionTable[i][j] = i + j;
}
}
//Print Array
for(int i = 0; i < rows; i++)
{
for(int j = 0; j < cols; j++)
{
printf("%d\t", additionTable[i][j]);
}
putchar('\n');
}

Copyright BlueSignet LLC. All rights reserved. For more visit WiBit.Net

i
0

rows
2

j
5

additionTable

cols
5

0 1 2 3

0 0 1 2 3

1 1 2 3 4

Programming in C

Two Dimensional Arrays: Using Loops


const int rows = 2, cols = 5;
int additionTable[rows][cols];
// Load Array
for(int i = 0; i < rows; i++)
{
for(int j = 0; j < cols; j++)
{
additionTable[i][j] = i + j;
}
}
//Print Array
for(int i = 0; i < rows; i++)
{
for(int j = 0; j < cols; j++)
{
printf("%d\t", additionTable[i][j]);
}
putchar('\n');
}

Copyright BlueSignet LLC. All rights reserved. For more visit WiBit.Net

i
0

rows
2

j
5

additionTable

cols
5

0 1 2 3

0 0 1 2 3

1 1 2 3 4

4\n

Programming in C

Two Dimensional Arrays: Using Loops


const int rows = 2, cols = 5;
int additionTable[rows][cols];
// Load Array
for(int i = 0; i < rows; i++)
{
for(int j = 0; j < cols; j++)
{
additionTable[i][j] = i + j;
}
}
//Print Array
for(int i = 0; i < rows; i++)
{
for(int j = 0; j < cols; j++)
{
printf("%d\t", additionTable[i][j]);
}
putchar('\n');
}

Copyright BlueSignet LLC. All rights reserved. For more visit WiBit.Net

i
1

rows
2

j
5

additionTable

cols
5

0 1 2 3

0 0 1 2 3

1 1 2 3 4

Programming in C

Two Dimensional Arrays: Using Loops


const int rows = 2, cols = 5;
int additionTable[rows][cols];
// Load Array
for(int i = 0; i < rows; i++)
{
for(int j = 0; j < cols; j++)
{
additionTable[i][j] = i + j;
}
}
//Print Array
for(int i = 0; i < rows; i++)
{
for(int j = 0; j < cols; j++)
{
printf("%d\t", additionTable[i][j]);
}
putchar('\n');
}

Copyright BlueSignet LLC. All rights reserved. For more visit WiBit.Net

i
1

rows
2

j
0

additionTable

cols
5

0 1 2 3

0 0 1 2 3

1 1 2 3 4

Programming in C

Two Dimensional Arrays: Using Loops


const int rows = 2, cols = 5;
int additionTable[rows][cols];
// Load Array
for(int i = 0; i < rows; i++)
{
for(int j = 0; j < cols; j++)
{
additionTable[i][j] = i + j;
}
}
//Print Array
for(int i = 0; i < rows; i++)
{
for(int j = 0; j < cols; j++)
{
printf("%d\t", additionTable[i][j]);
}
putchar('\n');
}

Copyright BlueSignet LLC. All rights reserved. For more visit WiBit.Net

i
1

rows
2

j
0

additionTable

cols
5

0
1

0 1 2 3

0 0 1 2 3

1 1 2 3 4

Programming in C

Two Dimensional Arrays: Using Loops


const int rows = 2, cols = 5;
int additionTable[rows][cols];
// Load Array
for(int i = 0; i < rows; i++)
{
for(int j = 0; j < cols; j++)
{
additionTable[i][j] = i + j;
}
}
//Print Array
for(int i = 0; i < rows; i++)
{
for(int j = 0; j < cols; j++)
{
printf("%d\t", additionTable[i][j]);
}
putchar('\n');
}

Copyright BlueSignet LLC. All rights reserved. For more visit WiBit.Net

i
1

rows
2

j
1

additionTable

cols
5

0
1

0 1 2 3

0 0 1 2 3

1 1 2 3 4

Programming in C

Two Dimensional Arrays: Using Loops


const int rows = 2, cols = 5;
int additionTable[rows][cols];
// Load Array
for(int i = 0; i < rows; i++)
{
for(int j = 0; j < cols; j++)
{
additionTable[i][j] = i + j;
}
}
//Print Array
for(int i = 0; i < rows; i++)
{
for(int j = 0; j < cols; j++)
{
printf("%d\t", additionTable[i][j]);
}
putchar('\n');
}

Copyright BlueSignet LLC. All rights reserved. For more visit WiBit.Net

i
1

rows
2

j
1

additionTable

cols
5

0
1

1
2

0 1 2 3

0 0 1 2 3

1 1 2 3 4

Programming in C

Two Dimensional Arrays: Using Loops


const int rows = 2, cols = 5;
int additionTable[rows][cols];
// Load Array
for(int i = 0; i < rows; i++)
{
for(int j = 0; j < cols; j++)
{
additionTable[i][j] = i + j;
}
}
//Print Array
for(int i = 0; i < rows; i++)
{
for(int j = 0; j < cols; j++)
{
printf("%d\t", additionTable[i][j]);
}
putchar('\n');
}

Copyright BlueSignet LLC. All rights reserved. For more visit WiBit.Net

i
1

rows
2

j
2

additionTable

cols
5

0
1

1
2

0 1 2 3

0 0 1 2 3

1 1 2 3 4

Programming in C

Two Dimensional Arrays: Using Loops


const int rows = 2, cols = 5;
int additionTable[rows][cols];
// Load Array
for(int i = 0; i < rows; i++)
{
for(int j = 0; j < cols; j++)
{
additionTable[i][j] = i + j;
}
}
//Print Array
for(int i = 0; i < rows; i++)
{
for(int j = 0; j < cols; j++)
{
printf("%d\t", additionTable[i][j]);
}
putchar('\n');
}

Copyright BlueSignet LLC. All rights reserved. For more visit WiBit.Net

i
1

rows
2

j
2

additionTable

cols
5

0
1

1
2

0 1 2 3

0 0 1 2 3

1 1 2 3 4

2
3

Programming in C

Two Dimensional Arrays: Using Loops


const int rows = 2, cols = 5;
int additionTable[rows][cols];
// Load Array
for(int i = 0; i < rows; i++)
{
for(int j = 0; j < cols; j++)
{
additionTable[i][j] = i + j;
}
}
//Print Array
for(int i = 0; i < rows; i++)
{
for(int j = 0; j < cols; j++)
{
printf("%d\t", additionTable[i][j]);
}
putchar('\n');
}

Copyright BlueSignet LLC. All rights reserved. For more visit WiBit.Net

i
1

rows
2

j
3

additionTable

cols
5

0
1

1
2

0 1 2 3

0 0 1 2 3

1 1 2 3 4

2
3

Programming in C

Two Dimensional Arrays: Using Loops


const int rows = 2, cols = 5;
int additionTable[rows][cols];
// Load Array
for(int i = 0; i < rows; i++)
{
for(int j = 0; j < cols; j++)
{
additionTable[i][j] = i + j;
}
}
//Print Array
for(int i = 0; i < rows; i++)
{
for(int j = 0; j < cols; j++)
{
printf("%d\t", additionTable[i][j]);
}
putchar('\n');
}

Copyright BlueSignet LLC. All rights reserved. For more visit WiBit.Net

i
1

rows
2

j
3

additionTable

cols
5

0
1

1
2

0 1 2 3

0 0 1 2 3

1 1 2 3 4

2
3

3
4

Programming in C

Two Dimensional Arrays: Using Loops


const int rows = 2, cols = 5;
int additionTable[rows][cols];
// Load Array
for(int i = 0; i < rows; i++)
{
for(int j = 0; j < cols; j++)
{
additionTable[i][j] = i + j;
}
}
//Print Array
for(int i = 0; i < rows; i++)
{
for(int j = 0; j < cols; j++)
{
printf("%d\t", additionTable[i][j]);
}
putchar('\n');
}

Copyright BlueSignet LLC. All rights reserved. For more visit WiBit.Net

i
1

rows
2

j
4

additionTable

cols
5

0
1

1
2

0 1 2 3

0 0 1 2 3

1 1 2 3 4

2
3

3
4

Programming in C

Two Dimensional Arrays: Using Loops


const int rows = 2, cols = 5;
int additionTable[rows][cols];
// Load Array
for(int i = 0; i < rows; i++)
{
for(int j = 0; j < cols; j++)
{
additionTable[i][j] = i + j;
}
}
//Print Array
for(int i = 0; i < rows; i++)
{
for(int j = 0; j < cols; j++)
{
printf("%d\t", additionTable[i][j]);
}
putchar('\n');
}

Copyright BlueSignet LLC. All rights reserved. For more visit WiBit.Net

i
1

rows
2

j
4

additionTable

cols
5

0
1

1
2

0 1 2 3

0 0 1 2 3

1 1 2 3 4

2
3

3
4

4
5

Programming in C

Two Dimensional Arrays: Using Loops


const int rows = 2, cols = 5;
int additionTable[rows][cols];
// Load Array
for(int i = 0; i < rows; i++)
{
for(int j = 0; j < cols; j++)
{
additionTable[i][j] = i + j;
}
}
//Print Array
for(int i = 0; i < rows; i++)
{
for(int j = 0; j < cols; j++)
{
printf("%d\t", additionTable[i][j]);
}
putchar('\n');
}

Copyright BlueSignet LLC. All rights reserved. For more visit WiBit.Net

i
1

rows
2

j
5

additionTable

cols
5

0
1

1
2

0 1 2 3

0 0 1 2 3

1 1 2 3 4

2
3

3
4

4
5

Programming in C

Two Dimensional Arrays: Using Loops


const int rows = 2, cols = 5;
int additionTable[rows][cols];
// Load Array
for(int i = 0; i < rows; i++)
{
for(int j = 0; j < cols; j++)
{
additionTable[i][j] = i + j;
}
}
//Print Array
for(int i = 0; i < rows; i++)
{
for(int j = 0; j < cols; j++)
{
printf("%d\t", additionTable[i][j]);
}
putchar('\n');
}

Copyright BlueSignet LLC. All rights reserved. For more visit WiBit.Net

i
1

rows
2

j
5

additionTable

cols
5

0
1

1
2

0 1 2 3

0 0 1 2 3

1 1 2 3 4

2
3

3
4

4
5\n

Programming in C

Two Dimensional Arrays: Using Loops


const int rows = 2, cols = 5;
int additionTable[rows][cols];
// Load Array
for(int i = 0; i < rows; i++)
{
for(int j = 0; j < cols; j++)
{
additionTable[i][j] = i + j;
}
}
//Print Array
for(int i = 0; i < rows; i++)
{
for(int j = 0; j < cols; j++)
{
printf("%d\t", additionTable[i][j]);
}
putchar('\n');
}

Copyright BlueSignet LLC. All rights reserved. For more visit WiBit.Net

i
2

rows
2

j
5

additionTable

cols
5

0
1

1
2

0 1 2 3

0 0 1 2 3

1 1 2 3 4

2
3

3
4

4
5\n

Programming in C

Two Dimensional Arrays: Using Loops


const int rows = 2, cols = 5;
int additionTable[rows][cols];
// Load Array
for(int i = 0; i < rows; i++)
{
for(int j = 0; j < cols; j++)
{
additionTable[i][j] = i + j;
}
}
//Print Array
for(int i = 0; i < rows; i++)
{
for(int j = 0; j < cols; j++)
{
printf("%d\t", additionTable[i][j]);
}
putchar('\n');
}

Copyright BlueSignet LLC. All rights reserved. For more visit WiBit.Net

0
1

1
2

2
3

3
4

4
5

Programming in C

Multidimensional Arrays
Any array that facilitates two or more dimensions

Two Dimensional
float twoDimArr[5][10];

Three Dimensional
long threeDimArr[8][20][50];

Four Dimensional
int fourDimArr[2][4][6][8];

Copyright BlueSignet LLC. All rights reserved. For more visit WiBit.Net

Programming in C

CStrings
Technically an array

char* myString = WiBit.net;

Copyright BlueSignet LLC. All rights reserved. For more visit WiBit.Net

Programming in C

CStrings
Technically an array

char* myString = WiBit.net;

\0

myString

Copyright BlueSignet LLC. All rights reserved. For more visit WiBit.Net

Programming in C

CStrings
Technically an array

char* myString = WiBit.net;


printf(%c, myString[0]);

\0

W
myString

Copyright BlueSignet LLC. All rights reserved. For more visit WiBit.Net

Programming in C

CStrings
Technically an array

char* myString = WiBit.net;


printf(%c, myString[9]);

\0

NULL
myString

Copyright BlueSignet LLC. All rights reserved. For more visit WiBit.Net

Programming in C

CStrings
What is the difference between char* and char[]?

Similarities

Single dimensional array


Pointers
Each character element is accessible

Differences

char* is static, read only (after declared), and globally


allocated

char[] is editable, read/write accessible, and locally


allocated

Is available even after local function usage (variable scope)

Is deallocated after local function usage (variable scope)

Data Types are NOT interchangeable

Copyright BlueSignet LLC. All rights reserved. For more visit WiBit.Net

Programming in C

Programming in C
The End
Thanks for watching!

Copyright BlueSignet LLC. All rights reserved. For more visit WiBit.Net

Das könnte Ihnen auch gefallen