CPPForSchool.com: User Defined Function Set 1: Assignment 9

9. Give the output of the following program.

#include <iostream>
using namespace std;

int global = 10;

void func(int &x, int y)
{
    x = x - y;
    y = x * 10;
    cout << x << ", " << y << '\n';
}

int main()
{
    int global = 7;
    func (::global, global);
    cout << global << ", " << ::global << '\n';
    
    func(global, ::global);
    cout << global << ", " << ::global << '\n';
    
    return 0;
} 

-------------------------------------------------

3, 100
7, 30
4, 40
4, 3



Comments

Popular posts from this blog

CPPForSchool.com: Variable, Operator & Expression Set 1: Assignment 9

CPPForSchool.com: Array - Single Dimension Set 1 Assignment 6

CPPForSchool.com: Variable, Operator & Expression Set 1: Assignment 8