Exercise
Functions: Greeting + Farewell
Objective
Write a C# program whose Main must be like this:
public static void Main()
{
SayHello();
SayGoodbye();
}
SayHello and SayGoodbye are functions that you must define and that will be called from inside Main.
Write Your C# Exercise
C# Exercise Example
// Importing the System namespace to access basic system functions
using System;
class Program
{
// Function to print a greeting message
public static void SayHello()
{
// Output a greeting message
Console.WriteLine("Hello, welcome to the program!");
}
// Function to print a farewell message
public static void SayGoodbye()
{
// Output a farewell message
Console.WriteLine("Goodbye, thanks for using the program!");
}
// Main method to call SayHello and SayGoodbye functions
public static void Main()
{
// Call the SayHello function to greet the user
SayHello();
// Call the SayGoodbye function to bid farewell to the user
SayGoodbye();
}
}