Lecture 6 Arrays
Lecture 6 Arrays
Outline
CSC 1113 • Arrays
Programming Techniques – Declare an array and accessing elements
• Types of array
– 1D Arrays
– Multi-Dimensional Arrays
Mrs.T.D.Gilmini
Senior Lecturer
Department of Computer Science
1
11/30/2023
2
11/30/2023
Array Types
• Single Dimensional Array / One Dimensional
Array
– used to store list of values of same datatype
– store a row of values
– called as one-dimensional arrays, Linear Arrays or
simply 1-D Arrays.
• Multi Dimensional Array
– array of arrays is called as multi dimensional array
– an array created with more than one dimension (size)
• 2 – D array
• 3 – D array
int arr[2][2] = {10,20,30,40};
int arr[3][2][2]={0,1,2,3,4,5,6,7,8,9,3,2}
3
11/30/2023
3-D Arrays
• Write C Program to find sum of all elements
of each row of a matrix
4
11/30/2023
Null character in C
• “%s” which can be used to directly print and • str gives the base address of this string
read strings
5
11/30/2023
String functions
• C supports a wide range of functions that
manipulate strings under <string.h> library
• To use them, you must include
the <string.h> header file in your program