C Control StatementsC FunctionsC ArrayC PointerC Dynamic MemoryC StringC MathC StructureC UnionC File HandlingC PreprocessorC Command LineC Misc |
C array questions
|
|
a. no output
b. compile time Error
c. Run time Error
d. Strings Equal
The correct option is (a)
Explanation:
In this program we comparing the base address of ‘a’ and ‘b’ and that are not same. Therefore the program has No output.
2.If pass an array as an arguments to a any function, what the actually get passed ?
a. Base address of the Array
b. First element of the array
c. values of the array elements
d. Address of the last element of array
The correct option is (a)
Explanation:
In C programming when we pass an array as an argument to the function , then the Base address of the array passed.
3. What is the right way to initialize an array ?
a. int num[6] = { 7, 7, 18, 3, 45, 5 };
b. int n{} = { 2, 3, 6, 5, 1, 1 };
c. int n{6} = { 2, 2, 13 };
d. int n(6) = { 2, 2, 22, 5, 2, 2 };
The correct option is (a)
Explanation:
Option b,c,d are wrong because in these options array declaration syntax is wrong, only square brackets [] are used to declare array.
4. What is the output of the following program ?
#include< stdio.h > |
a. 4
b. 6
c. 5
d. Error
The correct option is (b)
Explanation:
a[i] is equals to *(a + i),
so (arr+ 1)[5] is *(arr + 1 + 5), i.e. arr[6].
5. An Array elements always stored in ___________ memory location ?
a. Sequential
b. Sequential and random
c. Random
d. Non of these
The correct option is (a)
Explanation:
6. What will be print after execution of the program?
#include< stdio.h > |
a. Garbage value
b. 0
c. 6
d. 8
The correct option is (b)
Explanation:
When an array is initialized at the time of declaration then the remaining elements of the array is initialized to 0 by the compiler default.