What will be the output of the following C++ code?
#include <iostream>
using namespace std;
void Values(int n1, int n2 = 10)
{
using namespace std;
cout << "1st value: " << n1;
cout << "2nd value: " << n2;
}
int main()
{
Values(1);
Values(3, 4);
return 0;
}
a) 1st value: 1
10
3
4
b) 1st value: 1
10
3
10
c) compile time error
d) runtime error
Answer: a
Explanation: In this program, We are passing the values as by default values rules it is working.
Output:
1st value: 1
2nd value: 10
1st value: 3
2nd value: 4
Related Posts
People overcome natural language problems by _____________
The integrated circuit was invented by Jack Kilby of _____________
Research scientists all over the world are taking steps towards building computers with circuits patterned after the complex interconnections existing among the human brain’s nerve cells. What name is given to such type of computers?
Which type of actuator generates a good deal of power but tends to be messy?
In LISP, the function evaluates both and is _____________
Which of the following have people traditionally done better than computers?
A bidirectional feedback loop links computer modeling with _____________
Join The Discussion