Home » C++ Programming » Arrays » Question
  1. What will be the output of this program?
    #include 
    using namespace std;
    int arr1[] = {150, 50, 230, 130, 160};
    int arr2[] = {13, 15, 30, 28, 50};
    int temp, res = 0;
    int main()
    {
    for (temp = 0; temp < 5; temp++)
    {
    res += arr1[temp];
    }
    for (temp = 0; temp < 4; temp++)
    {
    res += arr2[temp];
    }
    cout << res;
    return 0;
    }

    1. 806
    2. 150
    3. 130
    4. 13
    5. 15
Correct Option: A

In this program we are adding the every element of two arrays. Finally we got output as 806.



Your comments will be displayed only after manual approval.