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;
}
Discussion:
11 comments Page 2 of 2.
Harshad said:
5 years ago
@All.
#include<iostream>
using namespace std;
int main()
{
int arr[] = {1, 2 ,3, 4, 5};
int (&zarr)[5] = arr;
for(int i = 0; i <= 4; i++)
{
arr[i] += arr[i];
}
for(int i = 0; i <= 4; i++)
cout<< zarr[i];
return 0;
}
The above program gives correct Output.
#include<iostream>
using namespace std;
int main()
{
int arr[] = {1, 2 ,3, 4, 5};
int (&zarr)[5] = arr;
for(int i = 0; i <= 4; i++)
{
arr[i] += arr[i];
}
for(int i = 0; i <= 4; i++)
cout<< zarr[i];
return 0;
}
The above program gives correct Output.
(1)
Post your comments here:
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers