C++ Programming
07-08-2009, 10:00 AM
Could someone pls explain the below question?
Q1 : In line1 the second parameter is referece to integer constant.
If so how is the value in 'x' changed to 4
Question:
#include
#include
using namespace std;
int mani(int (&arr)[10], const int& x)//Line1
{
for (int i = 0; i < 1; ++i)
arr[i] = arr[i] + x;
return x; //returns 4
}
int main(){
int arr[10] = {2, 3, 4, 5, 6, 7, 8, 9, 10, 11};
cout
Q1 : In line1 the second parameter is referece to integer constant.
If so how is the value in 'x' changed to 4
Question:
#include
#include
using namespace std;
int mani(int (&arr)[10], const int& x)//Line1
{
for (int i = 0; i < 1; ++i)
arr[i] = arr[i] + x;
return x; //returns 4
}
int main(){
int arr[10] = {2, 3, 4, 5, 6, 7, 8, 9, 10, 11};
cout