Functions

Hello guys. Why the function call just only have one,two,three respectively in this program.

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
36
37
38
39
40
41
42
43
44
45
46
47
48
#include <iostream>
#include <iomanip>
  
using namespace std;  

int volume(int l = 1, int w = 1, int h = 1);
void funcOne(int& x, double y = 12.34, char z = 'B');

int main()
{
    int a = 23;
    double b = 48.78;
    char ch = 'M';

    cout << fixed << showpoint;
    cout << setprecision(2);

    cout << "Line 1: a = " << a << ", b = "
         << b  << ", ch = " << ch << endl;        //Line 1
    cout << "Line 2: Volume = " << volume()
         << endl;                                 //Line 2
    cout << "Line 3: Volume = " << volume(5, 4)
         << endl;                                 //Line 3
    cout << "Line 4: Volume = " << volume(34)
         << endl;                                 //Line 4
    cout << "Line 5: Volume = "
         << volume(6, 4, 5) << endl;              //Line 5
    funcOne(a);                                   //Line 6
    funcOne(a, 42.68);                            //Line 7
    funcOne(a, 34.65, 'Q');                       //Line 8
    cout << "Line 9: a = " << a << ", b = "
         << b << ", ch = " << ch << endl;         //Line 9

    system ("Pause");
    return 0;
}

int volume(int l, int w, int h)
{
    return l * w * h;                             //Line 10
}

void funcOne(int& x, double y, char z)
{
    x = 2 * x;                                    //Line 11
    cout << "Line 12: x = " << x << ", y = "
          << y << ", z = " << z << endl;          //Line 12
}Put the code you need help with here.
1
2
3
funcOne(a);                                   //Line 6
funcOne(a, 42.68);                            //Line 7
 funcOne(a, 34.65, 'Q');


Output :
Line 12: x = 46 , y = 12.34 , z = B
Line 12: x = 92 , y = 42.68 , z = B
Line 12: x = 184 , y = 34.64 , z = Q

i confuse this part especially three of value x.
Help me please.
Last edited on
What do you mean?
I just forget about the reference. Now I realise about value of x.
Sorry Peter87 make you confuse what i meant.
Topic archived. No new replies allowed.