NEW
Font size
WorksheetsDAY 4 - Arrays & String Assessment _14 June 24
Total questions: 10
Worksheet time: 5mins
How do you declare a one-dimensional array of integers with 10 elements in C?
int array[10];
int array(10);
int array{10};
int array;
is the index of the last element in a one-dimensional array with 5 elements?
4
5
0
1
How do you access the element at the second row and third column of a two-dimensional array arr?
arr[2][3]
arr[1][2]
arr[3][2]
arr[2, 3]
What will be the output of the following C code snippet?
1
2
3
Compilation error
What is the correct syntax to initialize a two-dimensional array in C?
int arr[2][3] = {{1, 2, 3}, {4, 5, 6}};
int arr[2, 3] = {1, 2, 3, 4, 5, 6};
int arr{2, 3} = {1, 2, 3, 4, 5, 6};
int arr[2][3] = {1, 2, 3, 4, 5, 6};
How do you declare a string in C?
char str[10];
string str;
char str;
str[10] = char;
What is the correct way to initialize a string with the value "Hello"?
char str[] = "Hello";
char str[] = {'H', 'e', 'l', 'l', 'o'};
char str[5] = "Hello";
char str[5] = {'H', 'e', 'l', 'l', 'o'};
Which library function is used to find the length of a string in C?
strlen()
strcpy()
strcat()
strcmp()
What will be the output of the following C code snippet?
ello
Hello
H
Compilation error
What is the output of the following C code snippet?
W
l
o
r
