What will be the output of the following C++ code?
#include<iostream>
using namespace std;
int main()
{
int a = 5;
auto check = [&]()
{
a = 10;
};
check();
cout<<"Value of a: "<<a<<endl;
return 0;
}
#include<iostream>
using namespace std;
int main()
{
int a = 5;
auto check = [&]()
{
a = 10;
};
check();
cout<<"Value of a: "<<a<<endl;
return 0;
}A. Value of a: 5
B. Value of a: 10
C. Error
D. Segmentation fault
Answer: Option B

Join The Discussion