Comments
- What will happen when we use void in argument passing?
-
View Hint View Answer Discuss in Forum
NA
Correct Option: C
As void is not having any return value, it will not return the value to the caller.
- What is the output of this program?
#include
using namespace std;
int add(int p, int q);
int main()
{
int k = 7, L = 9;
cout << add(k, L) << endl;
return 0;
}
int add(int p, int q )
{
int sum = p + q;
p = 10;
return p + q;
}
-
View Hint View Answer Discuss in Forum
NA
Correct Option: D
The value of a has been changed to 10, So it returns as 19.
- What is the output of this program?
#include
using namespace std;
void square (int *p)
{
*p = (*p + 3) * (*p);
}
int main ( )
{
int n = 15;
square(&n);
cout << n;
return 0;
}
-
View Hint View Answer Discuss in Forum
NA
Correct Option: B
We have increased the x value in operand as p + 1, so it will return as 270.
- What is the output of this program?
#include
using namespace std;
long fact (long p)
{
if (p > 1)
return (p * fact (p + 1));
else
return (1);
}
int main ()
{
long n = 6;
cout << n << "! = " << fact ( n );
return 0;
}
-
View Hint View Answer Discuss in Forum
NA
Correct Option: C
As we have given in the function as p+1, it will exceed the size and so it arises the segmentation fault.
- What is the use of the indentation in c++?
-
View Hint View Answer Discuss in Forum
NA
Correct Option: B
the use of the indentation in c++ is distinguishes between comments and code.