Edit, compile, link, and save a short program that prints out:
hello, world
Mark your output with:
For Pascal the program is as follows:
{ Program to print "hello, world" } { L Taber September 4, 1997 PCC } { Converted to Pascal } { Kernighan & Richie "The C Programming Language" } { Copyright 1978 page 6 } program hello(input, output); begin writeln('hello, world'); end.
On my system, to run the FPK Pascal compiler, the file is named hello.pp, I enter
To run the program:ppc386 hello
hello
On my system, to run the FSF Gnu Pascal compiler (gpc), the file is named hello.p, I enter
To run the program:gpc -o hello hello.p
hello
For "C" the program is as follows:
/* Program to print "hello, world" */ /* L Taber October 13, 1992 PCC */ /* Kernighan & Richie "The C Programming Language" */ /* Copyright 1978 page 6 */ #include <stdio.h> main() { printf("hello, world\n"); }
On my system, to run the FSF Gnu "C" compiler (gcc), I enter
To run the program:gcc -o hello hello.c
hello
For FORTRAN the program is as follows:
! Program to print "hello, world" ! L Taber September 4, 1997 PCC ! Converted to FORTRAN ! Kernighan & Richie "The C Programming Language" ! Copyright 1978 page 6 PRINT *,'hello, world' STOP END
On my system, to run the FSF GNU Fortran compiler, the file is named hello.for, I enter
To run the program:g77 -o hello hello.for
hello
The simplest, but not suitable for this class is perl. The program is (in hello.p) as follows:
To run the program:#!/usr/bin/perl # The K&R hello world program print( "hello, world\n");
perl is an interpreted language. No compile step is necessary. Last, is Java. This is a product of Sun. The tag line is "Write once, run anywhere". A GREAT idea (if it works). The Java program is as follows (the file name was hello.java):./hello.p
To compile the program:/* Program to print "hello, world" */ /* L Taber September 4, 1997 PCC */ /* Converted to Java */ /* Kernighan & Richie "The C Programming Language" */ /* Copyright 1978 page 6 */ class Helloworld { public static void main(String args[]) { System.out.println("hello, world"); } }
To run the program with the java byte code interpreter you need to give the class name. The Java compiler should have produced a file with the name Helloworld.class. For example:javac hello.java
java Helloworld