- Course
- Functions A
- Function with reference parameters
Function with reference parameters
Last updated:
8/23/2020
⁃
Difficulty:
Intermediate
Create a function named Double to calculate the double of an integer number, and modify the data passed as an argument. It must be a void function and you must use refererence parameters.
Input
4
Output
8
Solution
using System;
public class FunctionReferenceParams
{
public static void Main(string[] args)
{
int number = Convert.ToInt32(Console.ReadLine());
Double(ref number);
Console.WriteLine(number);
}
public static void Double(ref int number)
{
number += number;
}
}