- Course
- Functions A
- Function with parameters
Function with parameters
Last updated:
8/23/2020
⁃
Difficulty:
Easy
Create a C# program that implements two methods to greet and say goodbye. The method of greeting has a parameter 'name' of text. Then you must run them from the main program.
Input
Jonny
Output
Hello Jonny
Good Bye!
Solution
using System;
class FunctionParameters
{
public static void Main(string[] args)
{
string name = Console.ReadLine();
Greeting(name);
Farewell();
}
public static void Greeting(string name)
{
Console.WriteLine("Hello {0}", name);
}
public static void Farewell()
{
Console.WriteLine("Good Bye!");
}
}