Define Looping ,Arrays and expamples of Arrays
Looping is also called an iterative or repetative control mechanism , where int set of statements are repeatedly exacused either for a fixed number of times or as long as as certain logic condition is true .
The while , do -while and for loop statements are the 3 powerful loop control structurals available in C . The while statements is a pre-test loop statement ( it is executed if only the expression is true ) and the do-while is a post-test lop statement (it is executed at least one.Than the exepressions evalueted for repeating the loop).
The "for"loop is used when the user know the number of impressions to be made . Sometimes , it becomes desirable to exist a loop or skip a part ofb loop in an intative process.
To do so ,the break and continue statements are used.
Array
An array is a data structure used to store collection of similar values under a given name .They are also called subscriped variables .Elements of arrays are stored in the contiguous memory locations.
Entering Data into an Array
Since array represents a collection of values ,so to input data into the indiviual elements of the Array , we make us of loo statments . If the actual size of the array is known in advance, then for loop is preffered to while loop or do -while loop .
Accessing the values of an Array
In any point of the program in which an array is visible ,we can access the values of its elements indiviually as if it was a normal variable , thus being able to both read and modify its value .The format is simple as :
name[index];
One pair of square brackets is used for each (1) one dimensional array dimension.
For example: one dimensional arrays has only one subsscript and it is viewed as row matrix or column matrix,
But , multi-dimensional arrays have more than one subscript , hence the name two -dimensional arrays and three -dimensional arrays and so on.
C does not supports strings .Data types but strings are handled as an array of characters .There is rich library of function for manipulating strings .
Declaration of two-dimensional Arrays
data type_array_name[row][column]:
0 Comments