← ppnm

Exercise "Hello, World!"

Tasks

  1. Instal csharp mono on you system. On many systems it is prepackaged by system developers. For example, on Debian based systems you install mono with the command

    sudo apt install mono-mcs
    
    (there are also "mono-devel" and "mono-complete" packages, but it seems that "mono-mcs" is enough for us).

    In Termux the command is

    apt install mono
    
    MacOS users might need to install mono from the mono-poject,
    [https://www.mono-project.com/download/stable/#download-mac],
    
    if the correponding Homebrew package isn't there (it seems like it's been deprecated).
  2. Create a directory for the exercise inside your repository, let's say "~/repos/ppnm/exercises/hello",

    mkdir -p ~/repos/ppnm/exercises/hello
  3. Go to your directory (remember to use the completion feature of your shell !):

    cd ~/repos/ppnm/exercises/hello
  4. Create a Makefile with the following content (mind the tabulators!) (and you can omit the comments):
    Out.txt : hello.exe              # Out.txt depends on hello.exe
    	mono hello.exe > Out.txt # run hello.exe, send output to Out.txt
    
    hello.exe : hello.cs             # hello.exe depends on hello.cs
    	mcs hello.cs             # compile hello.cs into hello.exe
    
    clean:                           # a phoney target, no dependencies
    	rm -f Out.txt hello.exe  # remove secondary files
    
  5. Create a file hello.cs with the following content
    class hello{
       static void Main(){
          System.Console.Write("hello\n");
       }
    }
    
  6. Run "make" and debug.
  7. Make the progam output "Hello, your-user-name!" where "your-user-name" is your user name.

Hints