Virtually all structured programs share a similar overall pattern:
- Statements to establish the start of the program
- Variable declaration
- Program statements (blocks of code)
The following is a simple example of a program written in several different programming languages. We call this the “Hello World” example since all the program does is print “Hello World” on the computer screen.
Language | Example program |
---|---|
“C” | #include <stdio.h> void main() { printf("Hello World"); } |
C++ | #include <iostream> int main() { cout << "Hello World"; return 0; } |
Pascal | program helloworld (output); begin writeln('Hello World'); end. |
Oracle PL/SQL | CREATE OR REPLACE PROCEDURE helloworld AS BEGIN DBMS_OUTPUT.PUT_LINE('Hello World'); END; |
Java | class helloworld { public static void main (String args []) { System.out.println ("Hello World"); } } |
Perl | #!/usr/local/bin/perl -w print "Hello World"; |
Basic | print "Hello World" |
Note that the Perl and Basic languages are technically not compiled languages. These language statements are “interpreted” as the program is running.