Programs:
A program is made up of a number of instructions and variables that when executed by a computer produce a useful result. As computers don't understand Spanish or any other human language programs are written in special languages named programming languages such as “C” “Java” “Logo”... etc. The instructions are stored in text files with extensions like .c, .java .lgo. The extension is related with the language used to write the instructions.
Here you can see examples of the simplest program that can be written in “C” “Java” and “Logo”. The program does nothing but writing “Hello World” on the computer's screen.
/**
* Hello world in C
*/
#include <stdio.h> main() { printf ("Hello World!\n"); }
/**
* Hello world in Java
*/
public class HelloWorld { public static void main(String[] args) { System.out.println("Hello, World"); }}
;
; Hello world in Logo
;
PARA HELLO ESCRIBE [Hello world] FIN
Here there's another more interesting program written in logo, it opens a window asking you a question.
para ventana
Sinobox [pregunta] [Te gusta la tecnologia]
fin
Now we'll try to write a program to make a simple videogame.
;You can drive the triangle as follows:
;press key 4 to turn left
;press key 6 to turn right
para game
ponfoco [Pantalla de MSWLogo]
ponteclado [control]
siempre [
avanza 5
espera 1
]
fin
para control
haz "tecla caracter leercar
si :tecla = 4 [giraizquierda 20]
si :tecla = 6 [giraderecha 20]
fin
Haz "tecla 6