Pointers And References In C Plus Plus - Study Mode
[#61] 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
}
Correct Answer
(A) 30
[#62] 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<<p
return 0
}
Correct Answer
(D) Compile-time error
[#63] What will be the output of the following C++ code? #include <iostream>
using namespace std
int func(void *Ptr)
int main()
{
char *Str = "abcdefghij"
func(Str)
return 0
}
int func(void *Ptr)
{
cout << Ptr
return 0
}
Correct Answer
(B) address of string "abcdefghij"
[#64] What will be the output of the following C++ code? #include <iostream>
using namespace std
int main()
{
int a = 5, c
void *p = &a
double b = 3.14
p = &b
c = a + b
cout << c << '
' << p
return 0
}
Correct Answer
(A) 8, memory address
[#65] What will be the output of the following C++ code? #include <iostream>
using namespace std
int main()
{
int arr[] = {4, 5, 6, 7}
int *p = (arr + 1)
cout << arr
return 0
}
Correct Answer
(C) address of arr