Functions And Procedures In C Plus Plus - Study Mode

[#116] What will be the output of the following C++ code? #include <iostream>
using namespace std
int func(int m = 10, int n)
{
int c
c = m + n
return c
}
int main()
{
cout << func(5)
return 0
}
Correct Answer

(C) compile time error

[#117] What will be the output of the following C++ code? #include <iostream>
using namespace std
int mult (int x, int y)
{
int result
result = 0
while (y != 0)
{
result = result + x
y = y - 1
}
return(result)
}
int main ()
{
int x = 5, y = 5
cout << mult(x, y)
return(0)
}
Correct Answer

(B) 25

[#118] What will be the output of the following C++ code? #include <iostream>
using namespace std
namespace space
{
int x = 10
}
namespace space
{
int y = 15
}
int main(int argc, char * argv[])
{
space::x = space::y =5
cout << space::x << space::y
}
Correct Answer

(C) 55

[#119] What will be the output of the following C++ code? #include <iostream>
using namespace std
void func(int a, bool flag = true)
{
if (flag == true )
{
cout << "Flag is true. a = " << a
}
else
{
cout << "Flag is false. a = " << a
}
}
int main()
{
func(200, false)
return 0
}
Correct Answer

(C) Flag is false. a = 200

[#120] What will be the output of the following C++ code? Content of header file h1.h
------------------------------------------------
h1.h
#include <iostream>
using namespace std
namespace A{
int func(int a){
cout<<"using namespace A"
return 2*a
}
}
------------------------------------------------

Content of header file h2.h
------------------------------------------------

h2.h
#include <iostream>
using namespace std
namespace B{
float func(float a){
cout<<"using namespace B"
return 2*a
}
}
------------------------------------------------

Content of program.cpp
------------------------------------------------

#include <iostream>
#include <string>
#include "h1.h"
#include "h2.h"
using namespace std
using namespace A
using namespace B
int main(int argc, char const *argv[])
{
/* code */
int a = 10
float b = 10.0
cout<<func(a)<<endl
cout<<func(b)
return 0
}
-----------------------------------------------
Correct Answer

(B) using namespace A20 using namespace B20