1. Which of the following correctly declares an array?
a) int array[10];
b) int array;
c) array{10};
d) array array[10];
2. What is the index number of the last element of an array with 9 elements?
a) 9
b) 8
c) 0
d) Programmer-defined
3. What is a array?
a) An array is a series of elements of the same type in contiguous memory locations
b) An array is a series of element
c) An array is a series of elements of the same type placed in non-contiguous memory locations
d) None of the mentioned
4. Which of the following accesses the seventh element stored in array?
a) array[6];
b) array[7];
c) array(7);
d) array;
5. Which of the following gives the memory address of the first element in array?
a) array[0];
b) array[1];
c) array(2);
d) array;
6. What will be the output of this program?
a) 6553
b) 6533
c) 6522
d) 12200
7. What will be the output of the this program?
a) 25
b) 26
c) 27
d) None of the mentioned
8. What is the output of this program?
a) 15
b) 18
c) garbage value
d) compile time error
9. What is the output of this program?
a) ABC
b) ABCD
c) AB
d) None of the mentioned
10. What is the output of this program?
a) -15
b) -30
c) compile time error
d) garbage value
a) int array[10];
b) int array;
c) array{10};
d) array array[10];
Answer:a
2. What is the index number of the last element of an array with 9 elements?
a) 9
b) 8
c) 0
d) Programmer-defined
Answer:b
3. What is a array?
a) An array is a series of elements of the same type in contiguous memory locations
b) An array is a series of element
c) An array is a series of elements of the same type placed in non-contiguous memory locations
d) None of the mentioned
Answer:a
4. Which of the following accesses the seventh element stored in array?
a) array[6];
b) array[7];
c) array(7);
d) array;
Answer:a
5. Which of the following gives the memory address of the first element in array?
a) array[0];
b) array[1];
c) array(2);
d) array;
Answer:d
6. What will be the output of this program?
#include <stdio.h>
using namespace std;
int array1[] = {1200, 200, 2300, 1230, 1543};
int array2[] = {12, 14, 16, 18, 20};
int temp, result = 0;
int main()
{
for (temp = 0; temp < 5; temp++) {
result += array1[temp];
}
for (temp = 0; temp < 4; temp++) {
result += array2[temp];
}
cout << result;
return 0;
}
b) 6533
c) 6522
d) 12200
Answer:b
7. What will be the output of the this program?
#include <stdio.h>
using namespace std;
int main ()
{
int array[] = {0, 2, 4, 6, 7, 5, 3};
int n, result = 0;
for (n = 0 ;n < 8 ;n++) {
result += array[n];
}
cout << result;
return 0;
}
b) 26
c) 27
d) None of the mentioned
Answer:c
8. What is the output of this program?
#include <stdio.h>
using namespace std;
int main()
{
int a = 5, b = 10, c = 15;
int arr[3] = {&a, &b, &c};
cout << *arr[*arr[1] - 8];
return 0;
}
b) 18
c) garbage value
d) compile time error
Answer:d
9. What is the output of this program?
#include <stdio.h>
using namespace std;
int main()
{
char str[5] = "ABC";
cout << str[3];
cout << str;
return 0;
}
b) ABCD
c) AB
d) None of the mentioned
Answer:a
10. What is the output of this program?
#include <stdio.h>
using namespace std;
int main()
{
int array[] = {10, 20, 30};
cout << -2[array];
return 0;
}
b) -30
c) compile time error
d) garbage value
Answer:b