C++ Programming - References - Discussion

Discussion Forum : References - Programs (Q.No. 12)
12.
Which of the following statement is correct about the program given below?
#include<iostream.h> 
int main()
{
    int arr[] = {1, 2 ,3, 4, 5}; 
    int &zarr = arr;
    for(int i = 0; i <= 4; i++)
    {
        arr[i] += arr[i];
    }
    for(i = 0; i <= 4; i++)
        cout<< zarr[i]; 
    return 0; 
}
The program will print the output 1 2 3 4 5.
The program will print the output 2 4 6 8 10.
The program will print the output 1 1 1 1 1.
It will result in a compile time error.
Answer: Option
Explanation:
No answer description is available. Let's discuss.
Discussion:
11 comments Page 2 of 2.

Virus said:   1 decade ago
There is an error in 5th line.

i.e. int &zarr = arr;

It must be &zarr = arr[5];


Post your comments here:

Your comments will be displayed after verification.