Font size
WorksheetsQuiz-1: Arrays
Total questions: 39
Worksheet time: 20mins
An Array is a collection of -
Different data types
Same data types
Both (a) and (b)
None of these
Array elements are stored in -
Scattered memory locations
Sequential memory locations
Both (a) and (b)
None of these
A character array is always ends with -
Null ('\0') character
Question Mark (?)
Full stop (.)
None of these
If you declare array without static the elements it will be set to -
A null value
zero
Garbage value
None of these
Arrays cannot be intialized if they are -
Automatic
external
static
None of the above
All the elements in the array must be -
Initialized
Defined
both (a) and (b)
None of the above
What will be the output of the following program - #include int main(){ int a1[5] = {1}; int b=0, k=0; for(b=0;b<=4;b++) print("%3d", ++a1[0]); return 0; }
a) 2 3 4 5 6
b) 1 2 3 4 5
How many integer values can the array N[5][5] store?
10
16
24
25
What index value should be used to access the last element of the integer array N[10]?
10
9
11
None of the above
The process of creating a fixed-sized array by allocating memory space at compile time is called __________ .
Static memory allocation
Run time memory allocation
Dynamic memory allocation
None of the above
An array N[3] = {1,2,3} has been declared and initialized in a C program. What will be the output of the following statement - printf("%d", N[3]);
3
2
4
Garbage value
An array ARR[5][20] has been declared. What will be the output of the following statement? printf("%d", sizeof(ARR));
100
200
400
800
The variable used as a subscript in an array is probably known as _______ variable.
Control
Index
Constant
None of the above
An array can be initialized -
Compile time
Run time
Array name -
A common name shared by all elements
An array variable
A keyboard
Not used in the program
Array subscript in C always start at -
-1
0
1
any value
An array of similar data types which themselves are a collection of dissimilar data type are
Linked Lists
Trees
Array of Structure
All of the mentioned
An array of similar data types which themselves are a collection of dissimilar data type are
Linked Lists
Trees
Array of Structure
All of the mentioned
Each element in an array has an index and the starting index is index 1.
True
False
Which control structure is used to repeatedly execute a block of code in C?
for loop
if statement
switch case
while loop
In C, what is the purpose of the 'break' statement within a loop?
Continue to the next iteration
Exit the program
Terminate the loop and exit it
Skip the current iteration
What is the purpose of the 'else' statement in C's 'if-else' control structure?
Execute the 'if' block
Execute the 'else' block
Execute both 'if' and 'else' blocks
Skip the 'if' block
Which control structure is used to make a decision between two or more alternatives in C?
switch case
for loop
if statement
while loop
What is the result of the expression 5 > 3 && 4 < 6 in C?
TRUE
FALSE
1
0
In C, what happens if the 'default' case is missing in a 'switch' statement?
It causes a compilation error
It has no effect
It executes the 'default' case by default
It generates a runtime error
What is the purpose of the 'continue' statement in C?
Skip the loop
Exit the program
Skip the current iteration
Exit the loop
How many times will a 'do-while' loop execute its body if the condition is initially false in C?
0 times
1 time
Infinite times
It depends on the loop body
What is the result of the expression !(5 == 5) in C?
TRUE
FALSE
1
0
In C, which control structure is used to iterate through a collection of items, such as an array or a list?
for loop
if statement
switch case
while loop
What is the purpose of the 'if' control structure in C?
Looping
Decision making
Function declaration
Error handling
What is the result of the expression 10 % 3 in C?
1
0
3
2
In C, what happens if the 'break' statement is used outside of a loop or switch statement?
It has no effect
It generates a compilation error
It exits the program
It generates a runtime error
Which control structure in C is used to perform a repetitive task while a condition is true?
if statement
for loop
while loop
switch case
What is the result of the expression `7 || 0` in C?
TRUE
FALSE
1
0
In C, what is the purpose of the 'goto' statement?
Break out of a loop
Terminate the program
Transfer control to a labelled statement
Execute a function
What does the 'default' case in a 'switch' statement do in C?
Executes when no other case matches
Causes a compilation error
Skips the 'switch' statement
Exits the program
How can you create an infinite loop in C?
Use a 'for' loop
Use a 'while' loop with a true condition
Use a 'do-while' loop
Use a 'switch' statement
What is the result of the expression 2 && 0 in C?
TRUE
FALSE
1
0
In C, which statement is used to exit the current iteration of a loop and continue with the next iteration?
break
return
continue
exit
