Call By Value And Call By Reference ...This Code Isn't Working .

Hi. Can Someone Plz Help With This Code. It Gives A Error When I compile It. Cant Figure Out What The Error Is:( I Use Dev c++ BTW

#include<iostream>

using namespace std;

int CBV(int);
void CBR(int&);

main()
{
int y=0;
cout<<"Enter A Number:";
cin>>y;
int ret=CBV(y);
cout<<"Call By Value: "<<ret;
cout<<"Call By Reference: "<<CBR(y);
cin.ignore();
cin.get();
}

int CBV(int x)
{
x=x*x;
return x;
}
void CBR(int& y)
{
y*y;
}

Last edited on
closed account (1vRz3TCk)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#include<iostream>

using namespace std;

int CBV(int);
void CBR(int&);

int main()
{
    int y = 0;

    cout << "Enter A Number:";
    cin >> y;
    
    int ret = CBV(y);
    CBR(y);
    
    cout << "Call By Value: " << ret << endl;
    cout << "Call By Reference: " << y << endl;
    
    cin.ignore();
    cin.get();

    return 0;
}

int CBV(int x)
{
    x = x * x;
    return x;
}
void CBR(int& y)
{
    y *= y;
}
Thanks :)
Topic archived. No new replies allowed.