- Course
- Functions A
- Function to calculate double a number
Function to calculate double a number
Last updated:
8/23/2020
⁃
Difficulty:
Intermediate
Create a C# program that implements a function called Double to calculate and return double an integer. You must first request the number from the user.
Input
- 4
Output
- 8
Solution
- using System;
- public class FunctionCalculateDouble
- {
- public static void Main(string[] args)
- {
- int number = Convert.ToInt32(Console.ReadLine());
-
- Console.WriteLine(Double(number));
- }
-
- public static int Double(int number)
- {
- return number + number;
- }
- }