Argument Passing

1

What is the output of this program?

1.
    #include 
2.    
    using namespace std;
3.    
    void Sum(int a, int b, int & c)
4.    
    {
5.    
        a = b + c;
6.        
        b = a + c;
7.        
        c = a + b;
8.        
    }
9.    
    int main()
10.    
    {
11.    
        int x = 2, y =3;
12.        
        Sum(x, y, y);
13.        
        cout << x << " " << y;
14.        
        return 0; 
15.        
    }
A. 2 3
B. 6 9
C. 2 15
D. compile time error

2

What will happen when we use void in argument passing?

A. It will not return value to its caller
B. It will return value to its caller
C. both a & b are correct
D. none of the mentioned

3

What is the output of this program?

1.
    #include 
2.    
    using namespace std;
3.    
    int add(int a, int b);
4.    
    int main()
5.    
    {
6.    
        int i = 5, j = 6;
7.        
        cout << add(i, j) << endl;
8.        
        return 0;
9.        
    }
10.    
    int add(int a, int b )
11.    
    {
12.    
        int sum = a + b;
13.        
        a = 7;
14.        
        return a + b;
15.        
    }
A. 11
B. 12
C. 13
D. compile time error

4

What is the output of this program?

1.
    #include 
2.    
    using namespace std;
3.    
    void square (int *x)
4.    
    {
5.    
	*x = (*x + 1) * (*x);
6.	
    }
7.    
    int main ( )
8.    
    {
9.    
	int num = 10;
10.	
        square(&num);
11.        
        cout << num; 
12.        
        return 0;
13.        
    }
A. 100
B. compile time error
C. 144
D. 110

5

What is the output of this program?

1.
    #include 
2.
    using namespace std;
3.
    long FACTORIAL (long a)
4.
    {
5.
        if (a > 1)
6.
            return (a * factorial (a + 1));
7.
        else
8.
            return (1);
9.
    }
10.
    int main ()
11.
    {
12.
        long num = 3;
13.
        cout << num << "! = " << factorial ( num );
14.
        return 0;
15.
    }
A. 6
B. 24
C. segmentation fault
D. compile time error