Sail E0 Webinar

MCQs

Total Questions : 33 | Page 2 of 4 pages
Question 11. What will be the output of the following code?
void main()
{
int a[10];
printf("%d %d", a[-1], a[12]);
}
  1.    0 0
  2.    Garbage value 0
  3.    0 Garbage Value
  4.    Garbage vlaue Garbage Value
  5.    Code will not compile
 Discuss Question
Answer: Option D. -> Garbage vlaue Garbage Value
Question 12. What does the following declaration mean?
int (*ptr)[10];
  1.    ptr is array of pointers to 10 integers
  2.    ptr is a pointer to an array of 10 integers
  3.    ptr is an array of 10 integers
  4.    ptr is an pointer to array
 Discuss Question
Answer: Option B. -> ptr is a pointer to an array of 10 integers
Question 13. Array passed as an argument to a function is interpreted as
  1.    Address of the array.
  2.    Values of the first elements of the array.
  3.    Address of the first element of the array.
  4.    Number of element of the array.
 Discuss Question
Answer: Option C. -> Address of the first element of the array.
Question 14. What will be the output of the program if the array begins at 65472 and each integer occupies 2 bytes?
#include
void main()
{
int a[3][4] = {1, 2, 3, 4, 4, 3, 2, 1, 7, 8, 9, 0};
printf("%u, %u", a+1, &a+1);
}
  1.    65474, 65488
  2.    65480, 65488
  3.    65480, 65496
  4.    65474, 65476
  5.    None of these
 Discuss Question
Answer: Option C. -> 65480, 65496
Question 15. What will be the output of the program ?
#include
int main()
{
int arr[1] = {10};
printf("%d", 0[arr]);
return 0;
}
  1.    1
  2.    0
  3.    10
  4.    6
  5.    None of these
 Discuss Question
Answer: Option C. -> 10
Question 16. What will be the output of the program if the array begins at address 65486?
#include
void main()
{
int arr[] = {12, 14, 15, 23, 45};
printf("%u, %u", arr, &arr);
}
  1.    65486, 65488
  2.    65486, 65490
  3.    65486, 65487
  4.    65486, 65486
  5.    None of these
 Discuss Question
Answer: Option D. -> 65486, 65486
Question 17. What will be the output of the program ?
#include
void main()
{
float arr[] = {12.4, 2.3, 4.5, 6.7};
printf("%d", sizeof(arr)/sizeof(arr[0]));
}
  1.    5
  2.    4
  3.    6
  4.    7
  5.    None of these
 Discuss Question
Answer: Option B. -> 4
Question 18. Which of the following statements are correct about the program below?
#include
void main()
{
int size, i;
scanf("%d", &size);
int arr[size];
for(i=1; i
  1.    The code is erroneous since the statement declaring array is invalid.
  2.    The code is erroneous since the subscript for array used in for loop is in the range 1 to size.
  3.    The code is correct and runs successfully.
  4.    The code is erroneous since the values of array are getting scanned through the loop.
  5.    None of these
 Discuss Question
Answer: Option A. -> The code is erroneous since the statement declaring array is invalid.
Question 19. Which of the following is correct way to define the function fun() in the below program?
#include
void main()
{
int a[3][4];
fun(a);
}
  1.    void fun(int p[][4]){}
  2.    void fun(int *p[4]){}
  3.    void fun(int *p[][4]){}
  4.    void fun(int *p[3][4]){}
  5.    None of these
 Discuss Question
Answer: Option A. -> void fun(int p[][4]){}
Question 20. Which of the following statements are correct about an array?
1. The array int num[26]; can store 26 elements.
2. The expression num[1] designates the very first element in the array.
3. It is necessary to initialize the array at the time of declaration.
4. The declaration num[SIZE] is allowed if SIZE is a macro.
  1.    1
  2.    1, 4
  3.    2, 3
  4.    2, 4
  5.    None of these
 Discuss Question
Answer: Option B. -> 1, 4

Latest Videos

Latest Test Papers