You are on page 1of 2

1. An array is a collection of data storage locations, each having the same ..

and the same



2. A single-dimensional array has only a single . A . is a number in brackets that
follows an array's name.
3. in an array int arr[12] the word arr represents the aof the array.
4. A is a .. while A is a.
5. .. function compares two strings to find out whether they are same or different.
6. strcpy() function. The contents of one string into another.
7. A ............... is a sequence of consecutive elements of type char that ends with the null character, '\0'

8. int array[4][3] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12 };


results in the following assignments:
array[3][1] is equal to 11, array[3][2] is equal to 12
9. How many dimensions can an array have?
a). 1 b). 3 c). 2 d). any number of depending on memory
10. If an array is declared with 10 elements, what is the subscript of the first element?
a). 1 b). 3 c). 2 d). 0
11. In a one-dimensional array declared with n elements, what is the subscript of the last element?
a). n+1 b). n c). 2 d). n-1
12. An array is declared with the following statement. How many total elements does the array have?
int array[2][3][5][8];
a). 15 b). 160 c). 200 d). none
13. What would be the name of the 10th element in the array in question int array[2][3][5][8];
14. Create an appropriate declaration for each of the following variables:
digits is an array of ten ints.
rates is an array of six floats.
mat is an array of three arrays of five integers.
pstr is a pointer to an array of 20 chars.
psa is an array of 20 pointers to char.
15. Declare an array of six ints and initialize it to the values 1, 2, 4, 8, 16, and 32.
17. Use array notation to represent the third element (the one with the value 4) of the array in part a.
18. What is the index range for a ten-element array?
16. Write a C program line that would declare three one-dimensional integer arrays, named one, two, and
three, with 1,000 elements each.
17. Write the statement that would declare a 10-element integer array and initialize all its elements to 1.
18. Describe the output of following code
int ab,b=0; int array[10];
static int int x = 1;
c[10]={1,2,3,4,5,6,7,8,9,0}; main()
for(a=0;a<10;a++) {
if((c[a]%2)==0)b+=c[a]; for ( x = 1; x <= 10; x++ )
printf(%d,b); array[x] = 99;
return 0;
}
int x, y; int array[10];
int array[10][3]; int x = 1;
main() main()
{ {
for ( x = 0; x < 3; for ( x = 1; x <= 10; x++ )
x++ ) array[x] = 99;
for ( y = 0; y < return 0;
10; y++ ) }
array[x][y] =
0;
return 0;
}
An array always occupies a continuous location in memory. The size of an array is thus the
number of elements times the size of the element type:
The length of the string is the number of characters excluding the string terminator '\0'.

While passing an array to the function, you have to specify the inner dimension to facilitate
calculations of the base addresses.

When an array is passed to a function, however, the values of the array elements are not passed
to the function.

If an array element is altered within the function, the alteration will not be recognized in the
calling portion of the program

There is limit to the number of dimensions a C array can have.

Write a program that replaces two or more consecutive blanks in a string by a single blank.

Given the following array, write code to initialize all the array elements to 0: int stuff[12][10];

Write a program to sort a list of string alphabetically using a 2-D character array.

You might also like