Functions And Procedures In C Plus Plus - Study Mode

[#126] What will be the output of the following C++ code? #include <iostream>
using namespace std
void func(int x)
{
cout << x
}
int main()
{
void (*n)(int)
n = &func
(*n)( 2 )
n( 2 )
return 0
}
Correct Answer

(D) 22

[#127] What will be the output of the following C++ code? #include <iostream>
using namespace std
void mani()
void mani()
{
cout<<"hai"
}
int main()
{
mani()
return 0
}
Correct Answer

(C) compile time error

[#128] What will be the output of the following C++ code? #include <iostream>
#include <string>
using namespace std
namespace
{
int var = 10
}
int main()
{
cout<<var
}
Correct Answer

(A) 10

[#129] What will be the output of the following C++ code? #include <iostream>
using namespace std
int operate (int a, int b)
{
return (a * b)
}
float operate (float a, float b)
{
return (a / b)
}
int main()
{
int x = 5, y = 2
float n = 5.0, m = 2.0
cout << operate(x, y) <<" "
cout << operate (n, m)
return 0
}
Correct Answer

(D) 10 2.5

[#130] What will be the output of the following C++ code? #include <iostream>
using namespace std
#define PR(id) cout << "The value of " #id " is "<<id
int main()
{
int i = 10
PR(i)
return 0
}
Correct Answer

(A) 10