Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

1_ What is the output? private void btnMethods_Click(object sender, EventArgs e)

ID: 3800256 • Letter: 1

Question

1_ What is the output?

private void btnMethods_Click(object sender, EventArgs e)

{

int arg1 = 2;

double val = ValReturnMethod(arg1, 2.00);

MessageBox.Show(val.ToString());

}

private void ValReturnMethod(int val, double val2)

{

return val1 * val2 *25.50;

}

_____________________________

2_ What is the output?

private void btnMethods_Click(object sender, EventArgs e)

{

int arg1 = 4;

double val = ValReturnMethod(ref arg1);

MessageBox.Show(arg1.ToString());

}

private double ValReturnMethod(ref int val1)

{

return val1 *25.50;

}

______________________________

3_ What is the output?

private void btnMethods_Click(object sender, EventArgs e)

{

int arg1 = 4;

double arg2 = 10.50;

MessageBox.Show(ValReturnMethod(arg1,arg2).ToString());

}

private double ValReturnMthod (int val1,double val2)

{

return val1 * 25.50;

}

___________________________

This is not C++ it is Visual C#

Explanation / Answer

1_ What is the output?

Answer: Code will not compile because we dont have return type in method header private void ValReturnMethod(int val, double val2)

it should be private doubleValReturnMethod(int val, double val2)

2_ What is the output?

Answer: 102

Since we are passing arg1 value as reference. The changes happend on that variable in function will reflect in actual copy of that variable. So arg1 value will display as 102.

3_ What is the output?

Answer: 102

Though w are passing arg1 and arg2 values, but we are suing arg1 value for calculation so arg1 value is 4 here.

4 * 25.50 = 102.

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote