Page 1 :
4.1, Array -, A kind of data structure that can, Store a fix Size. sequential c0llection OE, elements Of the same type. In another word,, Array is a collection of homogeneous data type, the, An array sg used to store a corlection, of data, but is more usefu to think of an, array as a collection of variables OF the, same type Instead Of deciaring individual, variable such as, number O, number 99, you can decia re one array ariable such., as numbers and use, numbers [0], hum bers [1], To represent individual variable, A sepecific element in an array is, numbers [99], access by an index, All array, element consists Of conti-, fquous memory locations. The lowest addre-, 55 COTrespondee to the Pirst element and, the highest addre6s to the last element, finstadt, element, last, element, numbersfonumbersft}, bao
Page 2 :
Page No., Date, have, to, * Declaration of Array, Name of an, Specifies the type of the element, array foliocwed by number of elements requiTe, by array., Syntax, dataty pe array, To declare an amay in Cwe, -name [size], array The size must be an integer constant, greater, c datatype, valid identifier., for example, To deciare, This is calHed ä single dimensinal, than o and datatype can be any valid, the array name, must be any, 1o elemenE array called balance, Of type double use these statements., double balnce efc10], Here balance is a variable name which, is SuFficient to hold up to 1o doable numbers, * Accessing array elements -, An element ia access by indexing, the array name This is done by placing, the index Of the elements within square, brackets after the name oF the, for example, double salary =, array, balance (9], Suppose we declare array of 5 elements,, element oÊ Array y04 can access by numberdo, first element we can a ccess by numbers [1] and, Second, the, 50 on.
Page 3 :
る, Page No., Data, Note, Suppose the starting address of num-, ber [0] is 2120 then the next addresS OF, and so on It's because the, will be 2122, size of integer, example, 2 bytes, int numbers [5], is, humbersfo] numbersti) numberst rumberfs]numbersto, 2120, 2122, 2124, 2126, 2128, float num balance C3], oatancefo batance[t}| balance E2]batance E$, 2120, 2124, 2128, 2132, * Initializing Arrays, you can initialize an arrany in C, or using Single statement as, either 1 by 1, follows, double balance [5] = { 3.4,5.3, 8.3,5.5.6.6 ;, If you ommit the size of array,, an array just be enough to hold the, initialization is created Therefore; if you, write, 6.6,, { 3.4., 9.9,10.10,l1.g¢, 5. 3, 8.3, 5.5, double balance [ ], compiler will generate or count the humbeY, Of elementS in amay an assighed that value, in array, count 9 elements and store it in balance, array., for example- Here compiler will
Page 4 :
Page No., 7., Dete, balan, bala nce (], loncelat, balance[o], balance[2], balance [6], balance[6) c balarel7], balancel], bolanel3], 9.9, to.10, 5.3, 8.3, 5.5, 7.8, 3.4, balance ro] is equal to, balance f] is equal to 5.3, balance [2] is equal to 8.3, balance [3) is equal to, balance [4] is equal to 6.6, balance (5] is equal to 7.8, balance (6] is equal to 9.9, balance 7 is equal to, balance [8] is equal to 119, 5.5, 10.10, 4615, How to insert and print array element, int marks [5], = { 19 ;10; 8,17,9}, Insert different vallue, to third element, marks I 3], Take input from ther user and insert in, third element, i scanf ("%d", { mark [2]);, Print first element, printf("%d" , mark [o])}, of an amay, print i th element, printf ("%d", mark (n-i)] :, of an aray