Paper Tayyari

Lecture 11: Arrays

MCQs, short and long questions from lecture 11.Lecture 11 ki MCQs, short aur long sawal.

4 MCQs · 4 MCQs from past papers4 MCQs · 4 MCQs past papers se

Start mock testMock test shuru karein
DoneHal kiye 0/4
– correctsahi
1.
★ Final term 2017 (paper 2)

What is the highest legal index for the following array? int arr[4]

  1. A4
  2. B3
  3. C2
  4. D1

Indexes run from 0 to size-1, so the last index is 3.

2.
★ Final term 2017 (paper 3)

Which of the following syntax will be used to initialize an array of size 5 of int data type to value 0?

  1. Aarr[5] = {0} ;
  2. Bint arr[5]= 0 ;
  3. Cint arr[5] = {0} ;
  4. Dint arr[] = 0 ;

An initializer list {0} sets the first element to 0 and the remaining elements are zero-initialized; the declaration needs the type.

3.
★ Final term solved MCQs (Moaaz & Asad)

In C/C++ if we define an array of size eight (8) i.e. int Arr [8]; then the last element of this array will be stored at,

  1. AArr[0]
  2. BArr[8]
  3. CArr[7]
  4. DArr[-1]

Indexes start at 0, so the last of 8 elements is Arr[7].

4.
★ Final term solved MCQs (Moaaz & Asad)

Suppose a program contains an array declared as int arr[100]; what will be the size of array?

  1. A0
  2. B99
  3. C100
  4. D101

The declared size is 100 elements (indexes 0 to 99).