Hello World Tutorial (revision 120925-r01KI)

Return to Lab 02

  • Create cobahello.c file using vi
    $ vi cobahello.c
    i
  • Type the below program. Replace 1202000818 with your student ID. Replace TOKEN with your token.
    //1202000818 sudah mengerjakan program "Hello, World!" 
    //ZCZC TOKEN
    
    #include <stdio.h>
    
    int main ()
    {
      printf ("Hello World!\n");
    }
    
  • Save the program.
    Esc
    :wq
    
  • Compile cobahello.c using gcc
    $ gcc cobahello.c
    $ ls -al
  • You will see a new file as a result: a.out. We can run this program using:
    $ ./a.out
  • We can also decide the file name for our executable. This time we will re-compile the program and make the executable named cobahello
    $ gcc -o cobahello cobahello.c
    ls -al
  • A new file named cobahello will be the result of the compilation. We can run this program with the same way like before.
    $ ./cobahello
  • This is the end of Hello World Tutorial.

Return to Lab 02
Kembali ke Wiki