Programming Course in C# ¡Free!

Function Double

 Saturday, April 06, 2013 published by Exercises C#
Proposed exercise

Create a function named "Double" to calculate and return an integer number doubled. For example. Double(7) should return 14.

Output



Solution


using System;
public class FDouble
{
public static int Double(int number)
{
return number + number;
}

public static void Main()
{
Console.Write("Enter a number: ");
int number = Convert.ToInt32(Console.ReadLine());
Console.WriteLine("Double of {0} is {1}",number,Double(number));
}
}