Introduction
- If the user did not supply the value, what value will it take?
-
View Hint View Answer Discuss in Forum
NA
Correct Option: B
If the user did not supply the value means, the compiler will take the given value in the argument list.
- Where can the default parameter be placed by the user?
-
View Hint View Answer Discuss in Forum
NA
Correct Option: A
rightmost
- Which value will it take when both user and default values are given?
-
View Hint View Answer Discuss in Forum
NA
Correct Option: C
The default value will be used when the user value is not given, So in this case, the user value will be taken.
- What is the output of this program?
#include
using namespace std;
void function(int p, bool condition = true)
{
if (condition == true )
{
cout << "Condition is true. P = " << p;
}
else
{
cout << "Condition is false. P = " << p;
}
}
int main()
{
function(250, false);
return 0;
}
-
View Hint View Answer Discuss in Forum
NA
Correct Option: C
In this program, we are passing the value, as it evaluates to false, it produces the output as following.
- What is the output of this program?
#include
#include
using namespace std;
string askMessage(string Message = "Please enter a message: ");
int main()
{
string Input = askMessage();
cout << "Here is your message: " << Input;
return 0;
}
string askMessage(string Message)
{
string Input;
cout << Message;
cin >> Input;
return Input;
}
-
View Hint View Answer Discuss in Forum
NA
Correct Option: D
In this program, we are getting a number and printing it.