c++ - confused about parameters by value and by reference -
assignment -
Create a sample function that takes at least three parameters, at least one parameter Price must be passed, and at least two should be passed by reference.
I have made the following but if I am doing the right thing then I am confused, I am confused about the value and from context
I have num1 = 30 in int1 Determine the addThree value to add to 7 but?
#include & lt; Iostream & gt; using namespace std; // prototype zero addThree (int num1, int and num2, int and num3); Int main () {int num1 = 30; Int number 2 = 50; Int number 3 = 80; AddThree (7, num2, num3); Return 0; } Zero addThree (int num1, int and num2, int and num3) {int x; Int y; Int z; X = num1 + 3; Y = num2 + 3; Z = num3 + 3; Cout & lt; & Lt; "X is value" & lt; & Lt; X & LT; & Lt; Endl; Cout & lt; & Lt; "Y Value" is & lt; & Lt; Y & lt; & Lt; Endl; Cout & lt; & Lt; "Z is value" & lt; & Lt; J & lt; & Lt; Endl;
There is no deep meaning in your code because I understand That is to show the difference between price and passing. By reference.
You can consider code that I will show as the idea of your code
#include & lt; Iostream & gt; Zero times (int and x, int and y, int n) {n / = 2; X * = n; Y * = N; } Int main () {int x, y; Int n; Std :: cout & lt; & Lt; "Enter X:"; Std :: cin & gt; & Gt; X; Std :: cout & lt; & Lt; "Enter y:"; Std :: cin & gt; & Gt; Y; Std :: cout & lt; & Lt; "Enter the factor:"; Std :: cin & gt; & Gt; N; Std :: cout & lt; & Lt; "Before multiplication.x =" & lt; & Lt; X & LT; & Lt; ", Y =" & lt; & Lt; Y & lt; & Lt; Std :: endl; Mylpli (X, Y, N); Std :: cout & lt; & Lt; "After multiplication.x =" & lt; & Lt; X & LT; & Lt; ", Y =" & lt; & Lt; Y & lt; & Lt; Std :: endl; }
Comments
Post a Comment