CPP

CPP

Arrays has 7 Questions

Which of the following correctly declares an array?

int array[10];
int array;
array{10};
array array[10];
What is the index number of the last element of an array with 9 elements?

9
8
0
Programmer-defined
What is a array?

An array is a series of elements of the same type in contiguous memory locations
An array is a series of element
An array is a series of elements of the same type placed in non-contiguous memory locations
None of the mentioned
Which of the following accesses the seventh element stored in array?

array[6];
array[7];
array(7);
array;
What will be the output of this program?
  1.     #include 
  2.     using namespace std;
  3.     int array1[] = {1200, 200, 2300, 1230, 1543};
  4.     int array2[] = {12, 14, 16, 18, 20};
  5.     int temp, result = 0;
  6.     int main()
  7.     {
  8.         for (temp = 0; temp < 5; temp++) {
  9.             result += array1[temp];
  10.         }
  11.         for (temp = 0; temp < 4; temp++) {
  12.             result += array2[temp];
  13.         }
  14.         cout << result;
  15.         return 0;
  16.     }

6553
6533
6522
12200
What will be the output of the this program?
  1.     #include 
  2.     using namespace std;
  3.     int main ()
  4.     {
  5.         int array[] = {0, 2, 4, 6, 7, 5, 3};
  6.         int n, result = 0;
  7.         for (n = 0; n < 8; n++) {
  8.             result += array[n];
  9.         }
  10.         cout << result;
  11.         return 0;
  12.     }

25
26
27
None of the mentioned

What is the output of this program?

  1.     #include <stdio.h>
  2.     using namespace std;
  3.     int main()
  4.     {
  5.         int a = 5, b = 10, c = 15;
  6.         int arr[3] = {&a, &b, &c};
  7.         cout << *arr[*arr[1] - 8];
  8.         return 0;
  9.     }

15
18
garbage value
compile time error