Class – XI Array Assignment

1.  An array element is accessed using

a.  first-in-first-out approach b. the dot operator

b.  a member name d. an index number

2.  What character ends all strings?
a. '.'
b. ' '
c. '\0'
d. '\n'

3.  When a multidimensional array is accessed, each array index is

a. separated by commas

b. surrounded by brackets and separated by commas

c. separated by commas and surrounded by brackets

d. surrounded by brackets

4.  The statement

int n [4] = {11, -13, 17, 105};

a. assigns the value -13 to [2].

b. assigns the value 17 to n[2].

c. is wrong; it gives an error message

d. assigns the value 18 to n[2].

5.  A string in the C++ language is represented by enclosing a series of characters in

a. single quotes. b. double quotes

c. parentheses. d. / and /

6.  The statement int num [2][3]= { {3,8,6}, {9,4,7} };

a. assigns a value 4 to num [1][2].

b. assigns a value 7 to num [1][2].

c assigns a value 8 to num [1][2].

d assigns a value 9 to num [1][2].

7.  The element of an array is

a. the name of the array b. a member of an array

c. a value assigned to an array d. All of the above.

8.  Two dimensional arrays are also called

a. tables arrays
b. matrix arrays
c. both of above
d. none of above

9.  The statement

float values[ ] = {3.14, -7.86, 36.96, 4.87};

a.  assigns 36.96 to values[2] b. assigns -7.86 to values[2]

b.  gives an error message d. assign 14 to values[2]

10.  The length of a string

Greater Noida is

a.  9. b. 13

b.  10. d 7.

11.  The statement

double val [15] ={80.123456};

a.  assigns the value 80.123456 to all members of the array val.

b.  assigns the value 80.123456 to val[0] and 0 to the rest of the members.

c.  gives an error message.

d.  assigns the value 80.123456 to val[1] and val[5].

12.  Point out the errors, if any, in the following program segments:

/* mixed has some char and some int values */

int char mixed[100] ;

main( )

{ int a[10], i ;

for ( i = 1 ; i <= 10 ; i++ )

{ cin> a[i] ;

cin> a[i] ; }

}

13.  Determine the size of the following one dimensional array:

a.  int arr[5];

b.  float arr[9];

c.  double arr[10];

d.  char [100];

14.  Write a function in C++ which accepts an integer array and its size as arguments and

replaces elements having even values with its half and elements having odd values with twice its value .

Example : If an array of five elements initially contains the elements as 3, 4, 5, 16, 9

then the function should rearrange content of the array as 6, 2, 10, 8, 18

15.  Write a function in C++ which accepts an integer array and its size as arguments and exchanges the values of first half side elements with the second half side elements of the array.

Example :

If an array of 8 elements initial content as 2, 4, 1, 6, 7, 9, 23, 10

The function should rearrange array as 7, 9, 23, 10, 2, 4, 1, 6

16.  Write a program for the problem: the array of integers indicating the marks of the students is given, U have to calculate the percentile of the

students according to this rule: the percentile of a student is the %of no of student having marks less then him. For eg:

suppose

Student Marks

A 12

B 60

C 80

D 71

E 30

F 45

percentile of C = 5/5 *100 = 100 (out of 5 students 5

are having marks less then him)

percentile of B = 3/5*100 = 60% (out of 5, 3 have

marks less then him)

percentile of A = 0/5*100 = 0%.

17.  Write a program to enter 10 integers in a single-dimension array and then print out the array in ascending order

18.  Write a program to capitalize 1st letter of each word defining a function passing array as a paramter.

19.  Write a program to check whether the string is palindrome or not.

20.  Write a function in C++ to count and display the number of lines starting with alphabet ‘A’ in a given lines of text: For example : output 2 in the given lines .

A fox is in the jungle.

the tiger is in the den.

A roses is red

sky is blue.