II-140 Programming Concepts
clrscr();
printf("%f",x[1]);
}
(a) The program will not run.
(b) The program will run with warning messages.
(c) None of the above.
(d) 0th element (c) 1st element
9. The total memory occupied by the array long k[4] is .
(a) 16
(b) 8
(c) 4
10. int x[2]={12,26}, then x[2] is .
(a) 0
(b) 15
(c) Garbage value
11. char c[]=“Hello” the H is stored at 65470, then the o is stored at .
(a) 65474
(b) 65475
(c) 65480
12. In int x[10]; the number 10 specified in the square bracket represents the .
(a) 10 addresses
(b) 10 values
(c) 10 lines
13. The first element according to C compiler physically is a .
(a) 2nd element
(b) 0th element
(c) 1st element
14. What is the index number of last element of an array containing 10 elements?
(a) 10
(b) 11
(c) 9
15. Which one of the following is correct declaration of an array?
(a) arr[5];
(b) int arr{5};
(c) int arr[5];
16. Which one of the following is correct declaration of two-dimensional array?
(a) arr arr[5];
(b) int arr[5][5];
(c) int arr[5]{5};
M07_ITL-ESL4791_02_SE_C07.indd 140 12/22/2012 5:03:01 PM
Array II-141
17. Array element of two dimensions is stored .
(a) Contagious memory locations
(b) Alternate memory locations
(c) Any locations
18. A character array always ends with .
(a) Null (‘’) character.
(b) Question Mark (?).
(c) Full Stop (.).
19. If you declare an array without static, the elements will be set to .
(a) Null value.
(b) Zero.
(c) Garbage value.
20. Arrays cannot be initialized if they are .
(a) Automatic
(b) External
(c) Static
(d) None of the above
21. All the elements in the array must be .
(a) Initialized
(b) Defined
(c) Both (a) and (b)
(d) None of the above
22. What will happen if you assign values in a few locations of an array ?
(a) Rest of the elements will be set to 0.
(b) Compiler error message will be displayed.
(c) Possibly system will crash.
23. The array name itself is pointer to .
(a) 0th element
(b) 1st element
(c) Last element
24. int x[3]; the base address of x is 65460, then all elements are stored at .
(a) 65460, 65462, 65464
(b) 65460, 65461, 65462
(c) 65460, 65464, 65468
25. int j[4] the sizeof( j) and sizeof (int) will display the value .
(a) 8, 2
(b) 2, 8
(c) 2, 2
26. Number of elements in an array between [ ] must be a (an) .
(a) Integer expression
(b) Character
M07_ITL-ESL4791_02_SE_C07.indd 141 12/22/2012 5:03:01 PM
II-142 Programming Concepts
(c) Float
(d) Double
27. How many rows and columns are there in int num[2][3]={ {1,2,3},{4,5,6} };?
(a) Two rows and three columns
(b) Three rows and two columns
(c) None of the above
28. What are the values of first row in int num[2][3]={ 1,2,3,4 };?
(a) 1, 2, 3,
(b) 2, 3, 4
(c) 1, 2, 4
29. What are the values of second row in int num[2][3]={ 1,2,3,4 };?
(a) 1, 2, 3,
(b) 2, 3, 4
(c) 4, 0, 0
30. What is the output of int num[2][3]={ {1,2,3,4},{3,4,5,6} };?
(a) 1, 2, 3,
(b) 2, 3, 4
(c) Compilation error
31. What is the value of a[1] in static int [3];?
(a) 1
(b) 2
(c) 0
32. A character array always ends with .
(a) Null (‘’) character
(b) Question Mark (?)
(c) Full Stop (.)
33. If you declare array without static, the elements will be set to .
(a) Null value
(b) Zero
(c) Garbage value
34. Assume name of the array is arr and its size is 10. What will be the address of first element of that
array arr?
(a) &arr[1];
(b) arr;
(c) &arr[-1];.
35. What will be the output of the following program?
#include <stdio.h>
#include <conio.h>
void main()
{
M07_ITL-ESL4791_02_SE_C07.indd 142 12/22/2012 5:03:01 PM
Array II-143
int a1[5]={1};
int b=0,k=0;
clrscr();
for(b=0;b<=4;b++)
{
printf("%3d",++a1[0]);
}
}
(a) 2 3 4 5 6
(b) 1 2 3 4 5
(c) 1 1 1 1 1 1
(d) 1 2 2 2 2 2
36. What will be the output of the following program?
void main()
{
int j[]={5,1,2,5,4,8};
int m[]={1,5,8,4,5,9};
int l[]={1,2,9,1,5,9},k;
for(k=0;k<6;k++)
l[k]=j[k]+m[k]-l[k];
clrscr();
for(k=0;k<6;k++)
(" %d ", l[k]);
}
(a) 5 4 1 8 4 8
(b) 5 5 1 8 4 9
(c) 1 2 5 5 5 9
37. What is the output of the following program?
void main()
{
int j[]={15,11,17,15,14,18};
int m[]={1,5,8,4,5,9};
int l[]={1,2,9,1,5,9},k;
for(k=0;k<6;k++)
l[k]=j[k]-m[k]/l[k];
clrscr();
M07_ITL-ESL4791_02_SE_C07.indd 143 12/22/2012 5:03:01 PM
II-144 Programming Concepts
for(k=0;k<6;k++)
printf(" %d ", l[k]);
}
(a) 14 9 17 11 13 17
(b) 12 8 16 10 12 16
(c) 14 19 17 10 12 11
38. What is the output of the following program?
void main()
{
char a[]={'A','B','C','D','E','F'};
char b[]={'0','1','2','3','4','4'};
char c[6],k;
for(k=0;k<6;k++)
c[k]=a[k]+b[k];
clrscr();
for(k=0;k<6;k++)
printf(" %c ", c[k]);
}
(a) q s u w y z
(b) Q S U W Y Z
(c) K J L M N O
39. If starting address of array int arr[5] = {5,4,3,2,1}; is 1042 then value 1 is at location
(a) 1048
(b) 1050
(c) 1046
(d) Same as the array i.e. 1042
40. The valid 2D-array definition is
(a) int b[][2] = {{1},{3,4}};
(b) int b[2][2] = {1,2,3,4};
(c) int b[][2] = {1,2,3};
(d) All of these
41. The general syntax for any type of array is
(a) data_type variable_name[size];
(b) data_type variable_name[];
(c) data_type variable_name[][] = initialization;
(d) data_type variable_name[size][];
42. The correct syntax for integer array in C is
(a) int b[3]; a[0]=1;a[1]=2;a[2]=3;
(b) int b[] = {1,2,3};
M07_ITL-ESL4791_02_SE_C07.indd 144 12/22/2012 5:03:01 PM
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset