238 Programming and Data Structures
Explanation In the above program a string is initialized with array name [ ]. The string is not
complete and contains blanks. The i f statement within the whi 1 e () loop checks every character of
the string. If blank space is found, i f block is executed and the user needs to enter a character.
Otherwise the next successive characters are displayed.
SUMM ARY
You have now learnt how to initialize an array by different ways .The Characteristics of array has
been discussed in depth. How to specify the elements of one-dimensional, two-dimensional and three
or multi dimensional arrays is explained in detail together with ample examples. The functions such
as the sscanf () and sprin t f () functions are demonstrated through examples. Perhaps this may be
the chapter in which the reader may find practical examples. The programmer should make an attempt
to execute all the programs so as to get expertise in arrays. Unless the unsolved problems are taken up
for solving the depth of the chapter would not be followed.
EXE R C ISES
A) A nswer the following questions.
1) Explain multi-dimensional array.
2) Array name contains base address of the array. Can we change the base address of the array?
3) What is the relation between an array name and an element number? How elements are referred
using base address?
4) Can we store values and addresses in the same array. Explain.
5) Mention the difference between character array and integer array.
B) A nsw er the following by selecting the appropriate option.
1) An array is a collection of
a) different data types. b) same data types,
c) both AandB.
2) Array elemets are stored in
a) scattered memory locations. b) sequential memory locations,
c) both (a) and (b).
3) A character array always ends with
a) null ('NO') character. b) question Mark (?).
c) full Stop (.).
4) If you declare array without stating the elements it will be set to
a) anull value. b) zero,
c) garbage Value.
5) Arrays can not be initalized if they are
a) automatic b) external
c) static d) none of the above