What will be the output of the following C++ code?
#include <iostream>
#include <string>
#include <cstdlib>
using namespace std;
int main(int argc, char const *argv[])
{
int &q = 5;
cout<<q;
return 0;
}
1 Crore+ students have signed up on EduRev. Have you? Download the App |
What will be the output of the following C++ code?
#include <iostream>
#include <string>
#include <cstdlib>
using namespace std;
int main(int argc, char const *argv[])
{
int a = 5;
int &p = a;
cout<<p;
return 0;
}
What will be the output of the following C++ code?
#include <iostream>
using namespace std;
void swap(int &a, int &b);
int main()
{
int a = 5, b = 10;
swap(a, b);
cout << "In main " << a << b;
return 0;
}
void swap(int &a, int &b)
{
int temp;
temp = a;
a = b;
b = temp;
cout << "In swap " << a << b;
}
What will be the output of the following C++ code?
#include<iostream>
using namespace std;
int &fun()
{
static int x = 10;
return x;
}
int main()
{
fun() = 30;
cout << fun();
return 0;
}
What will be the output of the following C++ code?
#include <iostream>
#include <string>
#include <cstdlib>
using namespace std;
int main(int argc, char const *argv[])
{
int a = 5;
int *p = &a;
int *(&q) = p;
cout<<q;
return 0;
}
What will be the output of the following C++ code?
#include <iostream>
using namespace std;
int main()
{
int a = 9;
int & aref = a;
a++;
cout << "The value of a is " << aref;
return 0;
}
What will be the output of the following C++ code?
#include<iostream>
using namespace std;
int main()
{
int x = 10;
int& ref = x;
ref = 20;
cout << x << endl ;
x = 30;
cout << ref << endl;
return 0;
}
Identify the correct sentence regarding inequality between reference and pointer.
What will be the output of the following C++ code?
#include <iostream>
using namespace std;
int f(int &x, int c)
{
c = c - 1;
if (c == 0) return 1;
x = x + 1;
return f(x, c) * x;
}
int main(int argc, char const *argv[])
{
int a = 4;
cout<<f(a,a);
return 0;
}