NEW
Font size
WorksheetsOCS752_CP_WEEKLY_TEST3 (20.08.2020)
Total questions: 20
Worksheet time: 20mins
What is an Array in C language.?
A group of element of same data type.
An array contains more than one element
Array elements are stored in memory in continuous or contiguous locations.
All the above.
what will be the output of the following in C?
#include<stdio.h>
int main()
{
int arr[1] = {10};
printf("%d",0[arr]);
return 0;
}
1
0
10
-1
What is the output of C Program.?
int main()
{
int a[];
a[4] = {1,2,3,4};
printf("%d", a[0]);
}
1
2
4
Compiler error
What is the output of C Program.?
int main()
{
int a[3] = {10,12,14};
a[1]=20;
int i=0;
while(i<3)
{
printf("%d ", a[i]); i++;
}
}
20 12 14
10 20 14
10 12 20
Compiler error
What is an array Base Address in C language.?
Base address is the address of 0th index element.
An array b[] base address is &b[0]
An array b[] base address can be printed with printf("%d", b);
All the above
An entire array is always passed by ___ to a called function.
Call by value
Call by reference
Address relocation
Address restructure
How do you initialize an array in C?
int arr[3] = (1,2,3);
int arr(3) = {1,2,3};
int arr[3] = {1,2,3};
int arr(3) = (1,2,3);
Elements in an array are accessed _____________
randomly
sequentially
exponentially
logarithmically
What are the elements present in the array of the following C code?
int array[5] = {5};
5, 5, 5, 5, 5
5, 0, 0, 0, 0
5, (garbage), (garbage), (garbage), (garbage)
(garbage), (garbage), (garbage), (garbage), 5
An array elements are stored in __________ memory locations.
sequential
random
sequential and random
None of the above
what will be the output of the following c code?
void main()
{
int a[10] = {1,2,3,4,5};
printf ("%d",a[5]);
}
5
6
0
Garbage value
what will be the output of the following C code?
void main()
{
int a[10];
printf("%d%d",a[-1],a[12]);
}
0 0
Garbage value 0
code will not compile
garbage value garbage value
what will be the output of this program?
void main()
{
float arr[] = { 10.2, 34.5, 65.4, 89.43 };
printf(%d", sizeof (arr) / sizeof (arr[0])) ;
}
5
4
7
0
What is the maximun number of dimensions an array in C may have?
Two
eight
sixteen
Theoretically no limit. The only practical limits are memory size and compilers
Let x be an array.Which of the following operations is illegal?
i) ++x.
ii) x+1.
iii) x++.
iv) x*2
I and II
I, II and III
II and III
III and IV
What will be the address of the arr[2][3] if arr is a 2-D long array of 4 rows and 5 columns and starting address of the array is 4000?
4048
4056
4052
4042
Size of the array need not be specified, when
Initialization is a part of definition
It is a declaratrion
It is a formal parameter
All of these
Consider the array definition
int num [10] = {3, 3, 3};
Pick the Correct answers
num [9] is the last element of the array num
The value of num [ 8] is 3
The value of num [ 3 ] is 3
None of the above
Consider the statement
int val[2] [4] = { 1, 2, 3, 4, 5, 6, 7, 8} ;
4 will be the value of
val[0 ][ 3]
val[0][4]
val[1][1]
none of the above
Which of the following is a two-dimensional array?
array anarray[20][20];
int anarray[20][20];
int array[20, 20];
char array[20];
