What will be the output of the following C++ code?
#include <stdio.h>
#include <iostream>
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;
}
a) 6553
b) 6533
c) 6522
d) 12200
Answer: b
Explanation: In this program we are adding the every element of two arrays. Finally we got output as 6533.
Related Posts
What does ~4 evaluate to?
What is the type of inf?
Which of the following is not a complex number?
What is the output of print 0.1 + 0.2 == 0.3?
What is the return value of trunc()?
Which of the following results in a SyntaxError?
In order to store values in terms of key and value we use what core data type.
Join The Discussion