Computer Science, asked by mesonalisharma99, 11 months ago

//assume size of integer to be 4 bytes
#include
int main()
{
int i = 5;
int &r = i;
std::cout << &r << "\\n";
r+=2;
std::cout << &r << "\\n";
return 0;
}

What will be the output of second count

Answers

Answered by Thithyamuthuraman
0

Answer:

the output of the second count is 7.

Answered by codiepienagoya
0

Output of the second cout is:

Output:

7

Explanation:

In the given code there is some error because of this it will print the garbage value so, the correct program to this question can be described as follows:

Program:

#include<iostream> //defining header file

int main()//defining main method

{

int i = 5; //defining integer variable i and assin value

int &r = i; //defining integer variable r with addresss operator

std::cout << r << "\n"; //print value

r=r+2;//increment the value by 2.

std::cout << r << "\n"; //print value

return 0;

}

Explanation:

  • In the above code an integer variable "i" is declared, that assign a value that is "5", in the next line an integer variable "&r" is declared, which holds "i" variable value.
  • In the next step two "cout" print method is used, that prints its variable r value. In the first print method, it will print the variable "r" value, that is 5. then increment variable "r" value by 2, and print its value that is 7.  

Learn more:

Output of the code: https://brainly.in/question/14887111

Similar questions