Sail E0 Webinar
Question


What is the output of this program?


1.
#include
2.
using namespace std;
3.
void fun(int x, int y)
4.
{
5.
x = 20;
6.
y = 10;
7.
}
8.
int main()
9.
{
10.
int x = 10;
11.
fun(x, x);
12.
cout
Options:
A .  10
B .  20
C .  compile time error
D .  none of the mentioned
Answer: Option A

In this program, we called by value so the value will not be changed, So the output is 10
Output:
$ g++ fun.cpp
$ a.out
10



Was this answer helpful ?
Next Question

Submit Solution

Your email address will not be published. Required fields are marked *

Latest Videos

Latest Test Papers