Sail E0 Webinar
Question


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
Options:
A .  6553
B .  6533
C .  6522
D .  12200
Answer: Option B

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



Was this answer helpful ?
Next Question

Submit Solution

Your email address will not be published. Required fields are marked *

Latest Videos

Latest Test Papers