MCQs
It's just printing the negative value of the concern element.
$ g++ array.cpp
$ a.out
-30
We are just printing the values of first 3 values.
$ g++ array.cpp
$ a.out
ABC
The conversion is invalid in this array. So it will arise error. The following compilation error
will be raised:
cannot convert from 'int *' to 'int'
We are adding all the elements in the array and printing it. Total elements in the array is 7, but
our for loop will go beyond 7 and add a garbage value.
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
In this program we are adding the every element of two arrays. Finally we got output as 6533.
Output:
$ g++ array.cpp
$ a.out
6533
The array location starts from zero, So it can accessed by array[6].
Because the first element always starts at 0. So it is on 8 position.
Because array variable and values need to be declared after the datatype only.
None.
None.