Array & string
-
Upload
prabhu-govind -
Category
Education
-
view
104 -
download
0
description
Transcript of Array & string
![Page 1: Array & string](https://reader036.fdocuments.net/reader036/viewer/2022082416/548b68d8b479596f608b49f6/html5/thumbnails/1.jpg)
ARRAYS
![Page 2: Array & string](https://reader036.fdocuments.net/reader036/viewer/2022082416/548b68d8b479596f608b49f6/html5/thumbnails/2.jpg)
ARRAYS
Arrays are collection of data that belong to similar data type
Arrays are collection of homogeneous dataArray elements can be accessed by its
position in the array called as index
![Page 3: Array & string](https://reader036.fdocuments.net/reader036/viewer/2022082416/548b68d8b479596f608b49f6/html5/thumbnails/3.jpg)
Arrays(Contd.)Array index starts with zeroThe last index in an array is num – 1 where num
is the no of elements in a arrayint a[5] is an array that stores 5 integersa[0] is the first element where as a[4] is the fifth
elementWe can also have arrays with more than one
dimensionfloat a[5][5] is a two dimensional array. It can
store 5x5 = 25 floating point numbersThe bounds are a[0][0] to a[4][4]
![Page 4: Array & string](https://reader036.fdocuments.net/reader036/viewer/2022082416/548b68d8b479596f608b49f6/html5/thumbnails/4.jpg)
String functionsstrlen(str) – To find length of string strstrrev(str) – Reverses the string str as rtsstrcat(str1,str2) – Appends str2 to str1 and
returns str1strcpy(st1,st2) – copies the content of st2 to
st1strcmp(s1,s2) – Compares the two string s1
and s2strcmpi(s1,s2) – Case insensitive comparison
of strings