Sail E0 Webinar

MCQs

Total Questions : 7
Question 1. Which of the following correctly declares an array?
  1.    int array[10];
  2.    int array;
  3.    array{10};
  4.    array array[10];
 Discuss Question
Answer: Option A. -> int array[10];


Because array variable and values need to be declared after the datatype only.


Question 2. Which of the following gives the memory address of the first element in array?
  1.    array[0];
  2.    array[1];
  3.    array(2);
  4.    array;
 Discuss Question
Answer: Option D. -> array;


array;


Question 3. Which of the following accesses the seventh element stored in array?
  1.    array[6];
  2.    array[7];
  3.    array(7);
  4.    array;
 Discuss Question
Answer: Option A. -> array[6];


The array location starts from zero, So it can accessed by array[6].


Question 4. What is the index number of the last element of an array with 9 elements?
  1.    9
  2.    8
  3.    0
  4.    Programmer-defined
 Discuss Question
Answer: Option B. -> 8


Because the first element always starts at 0. So it is on 8 position.


Question 5. What is a array?
  1.    n array is a series of elements of the same type in contiguous memory locations
  2.    An array is a series of element
  3.    An array is a series of elements of the same type placed in non-contiguous memory locations
  4.    None of the mentioned
 Discuss Question
Answer: Option A. -> n array is a series of elements of the same type in contiguous memory locations


n array is a series of elements of the same type in contiguous memory locations


Question 6.

What is the output of this program?

#include < stdio.h >

using namespace std;

int main()

{

char str[5] = "ABC";

cout

  1.    ABC
  2.    ABCD
  3.    AB
  4.    None of the mentioned
 Discuss Question
Answer: Option A. -> ABC


We are just printing the values of first 3 values.


Question 7.

What is the output of this program?

#include < stdio.h >

using namespace std;

int main()

{

int array[] = {10, 20, 30};

cout

  1.    -15
  2.    -30
  3.    compile time error
  4.    garbage value
 Discuss Question
Answer: Option B. -> -30


It's just printing the negative value of the concern element.


Latest Videos

Latest Test Papers