Sample C Programming Quiz Questions on Arrays.

Sno
Question
Option 1
Option 2
Option 3
Option 4
Answer
  1.
Which of the following correctly declares an array?
int array[10];
int array;
array{10};
array array[10];
1
  2.
What is the index number of the last element of an array with 29 elements?
29
28
0
Programmer-defined
2
  3.
Which of the following is a two-dimensional array?
array array[20][20];
int array[20][20];
int array[20, 20];
char array[20];
2
  4.
Which of the following correctly accesses the seventh element stored in array N with 100 elements?
N[6];
N[7];
N(7);
N;
1
  5.
What is right way to Initialize an array?
int num[6] = { 2, 4, 12, 5, 45, 5 };
int n{} = { 2, 4, 12, 5, 45, 5 };
int n{6} = { 2, 4, 12 };
int n(6) = { 2, 4, 12, 5, 45, 5 };
1
  6.
Array elements are always stored in ________ memory locations.
Sequential
Random
Sequential and Random
None of the above
1
  7.
What is the maximum number of dimensions an array in C may have?
Two
Three
Theoretically no limit. The only practical limits are memory size and compilers
None of the above.
3
  8.
What character ends all strings?
‘.'
' '
'\0'
'\n'
3
  9.
What is an Array?
An array is a collection of variables of dissimilar data type
An array is a collection of variables of similar data type
An array is not a collection of variables of similar data type
None of the above
2
  10.
The index or subscript value for an array of size ‘n’ ranges from
0 to n
1 to n-1
0 to n-1
None of the above
3
  11.
int val[2][4]={1,2,3,4,5,6,7,8 }; What is the index of value 4 ?
val[1][4]
val [0] [3]
val[1][1]
val[0][4]
2
  12.
The header file that must be included at the beginning of a C program to use a library function strlen() is
math.h
stdio.h
conio.h
string.h
4
  13.
If the two strings are identical, then strcmp() function returns
1
0
-1
None of the above
2
  14.
Which of the following functions compares two strings?
compare();
stringcompare();
cmp();
strcmp();
4
  15.
The library function used to reverse a string is
rev()
reverse()
stringreverse()
strrev()
4
  16.
The memory address of the first element of an array is called
floor address
foundation address
first address
base address
4
  17.
Which of the following function is more appropriate for reading in a multi-word string?
scanf()
gets()
printf()
puts()
2
  18.
int a[5] = {1,2,3} What is the value of a[4]?
3
1
0
Garbage value
3
  19.
String concatenation means
combining two strings
extracting a substring out ofa string
copying a string into another string
comparing the strings
1
  20.
Assuming int is of 4bytes, what is the size of int arr[15];?
15
19
11
60
4
  21.
How will you print "ECE" on the screen?
printf("ECE");
printf(""ECE"");
printf("\"ECE\"");
printf(ECE);
3
  22.
Smallest element of an array is called as
upper bound
lower bound
middle bound
index
2
  23.
strcpy(s1,s2)
s1 source, s2 destination
s1 destination, s2 source
s1 copied to s2
None of the given
2
  24.
void main() { int a[5]={5,1,15,20,25}; inti,j,m; i=++a[1]; j=a[1]++; m=a[i++]; printf("%d,%d,%d",i,j,m); }
3,2,15
2,3,20
2,1,15
1,2,5
1
  25.
void main() { float arr[]={12.4,2.3,4.5,6.7}; printf("%d",sizeof(arr)/sizeof(arr[0])); }
5
4
6
7
2
  26.
Array is an example of _______ type memory allocation.
static memory
dynamic memory
1 and 2
none
1
  27.
String is ______
collection of characters
character array
1 and 2
none
3
  28.
int a=10, b=20; a=a+b; a=a-b; b=a-b; printf("%d,%d",a,b);
10,20
20,10
10,10
20,20
2
  29.
What is the string termination character?
\0
-1
NULL
null
1
  30.
if(strcmp("lbrce","lbrce")) printf("equal"); else printf("not equal");
equal
not equal
equal not equal
error
2

Comments

Popular posts from this blog

MapReduce Matrix Multiplication Code

Word Count MapReduce Code

Step by step procedure for HADOOP installation on UBUNTU