Fundamentals of Computer Programming
References
Fundamentals of Computer Programming

Many who initially feel computer programming is not for them become accomplished programmers. Programming is initially difficult. However, programming is analogous to other difficult adventures that can lead to an unexpected feeling of accomplishment and source of self pride.

Computer programmers write programs in a variety of computer languages. Learning to code in a new computer language becomes increasingly easy with each new language learned. Learning your first computer language can take the most time because of the need to learn programming language fundamentals.

The most effective way to begin learning any new programming language is to start with a very simple programming language construct , such as print of the literal string "Hello World". The next step is to expand your capability with the new programming language by reviewing and modifying sample code focusing on the programming language specific syntax constructs that are fundamental to most programming languages - "how to code the":

  1. Operators
      Arithmetic
      Logical
      Relational
  2. Statements
  3. Expressions
  4. Sequences
  5. Selection process
  6. Loop process
  7. Data String Manipulation
  8. General and Program Constructs
  9. Functions
  10. Program Interfaces for Data Input and Data Output


1. Operators
Arithmetic Operators are:

  • ADD +
  • SUBSTRACT -
  • MULTIPLY *
  • DIVIDE /

Relational Operators are:
  • EQUAL =
  • LESS THAN <
  • MORE THAN >
Logical Operators are:
  • AND &&
  • OR ||
  • NOT !

Specific programming languages will use the operator symbol, the operator english word and in some cases, the programming language will accept either.


2. Statements vs. 3. Expressions
  • A statement is the smallest standalone element of a programming language where an action is to be carried out.
  • Statements are executed. Statements do something. Statements are instructions to be followed.
     An example would be setting a variable A to a value of 5
      A = 5.
  • Expressions produce at least one value.
     An example of an expression where the value is true or false.
     Given: A = 5 and B = 10
      Is A > B
      where this expression would return a true or false value.
  • Remember the difference between statements and expressions:
      A statement is executed and will do something, while an expression evaluates something returning a value.
      A statement can act upon a value returned by an expression.
      Statements can include expressions or other statements enabling the programming languages to be highly flexible and allow for creative programming techniques.

4. Sequence
  • Sequence is one of three basic logical structures in computer programming.
  • Sequence is effectively a list of statements.
      statement1;
      statement2;
      ...
      statement9;
  • While a program could be a list of statements executed in sequential order, this is typically NOT the case.
  • A statement action or event can determine the next statement to be executed. Therefore, a program is more than just a list of statements to be executed in sequential order.

5. Selection Process
  • Selection is one of three basic logical structures in computer programming. The other two are sequence and loop.
  • Selection involves use of a conditional expression to determine next statement to execute.
  • Selection is to make a decision based upon answer to a question in the program.
     IF (<Conditional Expression>)
      THEN <Statement>;
      ELSE <Statement>;
     ENDIF
     IF (A > B)
      THEN Print A + "is bigger";
      ELSE Print B + "is bigger";
     ENDIF;
  • IF/THEN/ELSE is only one programming language form for constructing program selection logic.
  • Other examples of programming language verbs for program selection logic include SELECT, WHILE, CASE, etc.

6. Loop Process
  • Loop is one of three basic logical structures in computer programming.
  • do something repeatedly (a loop)
     WHILE (<conditional expression>)
      DO (<statements>);
     ENDWHILE;

     A = 1;
     WHILE (A < 5)
      DO Print A;
       A = A + 1;
     ENDWHILE;
  • WHILE DO is only one programming language form for constructing program loop logic.
  • An example of other programming language verbs for program loops include FOR, DO UNTIL, etc.

7. Data String Manipulation
  • A string is traditionally a sequence of characters, either as a literal constant or as some kind of variable.
  • A string may also denote more general arrays or other sequence (or list) data types and structures.
  • Each programming language syntax includes a set of reserved keywords and techniques for reading, redefining, evaluating and changing strings.
  • Programming language reference manuals include a section for handling strings.

8. General and Program Constructs
  • Each operating system environment and each programming language may have separate ways to assign a name to the program, compile, and execute the named program.
  • Each programming language includes a set of reserved keywords for operators, statements, expressions, selection, and loops.
  • Each programming language includes a set of reserved keywords for describing various data types such as character, numeric, or packed decimal.
  • As a result, learning a new programming language requires review of documentation describing the programming language reserved keywords, etc. as well as familiarity with how to name, compile, and execute the program language within a target operating system.
  • Start learning the constructs using simple sample code and sample execution procedures.
      The next few challenges will use simple sample code along with relatively simple execution procedures.

9. Functions
  • Functions are small units of programs used to carry out specific task.
  • Functions are small "self contained" modules of code that accomplish a specific task.
  • Functions usually "take in" data, process it, and return a result.
  • Once a function is written, it can be used over and over and over again.
  • While it is possible to write a specific function within a program, each programming language has many powerful built-in functions.
     Example given A = "this is a long sentence"
    length(A) where length is the programming language function that would return a value of 23.
  • Functions can be "called" from the inside of other functions
  • Different programming languages name functions differently, for example, methods, sub-routines, procedures, etc. If you come across any such terminology, then just imagine the same concept. However, be aware of the technical purists that want to explain why they are not exactly the same across the various programming languages.

10. Program Interfaces for Data Input and Data Output
  • Programming language input and output syntax typically falls into 1 of 2 categories
      1. Reading from and writing to interactive session display
      2. Reading from and writing to operating system controlled sources of data using the operating system data access method.
  • The programming language syntax for interactive session reading and writing may be different from the programming language verbs for reading and writing to operating system controlled data sources.
  • Learning how to use the programming language syntax for reading and writing is best accomplished by looking at sample code, then reviewing the programming language manual for the target operating system to investigate all the available input and output capability of the specific programming language.

The above terminology and description of programming language fundamentals will be used in the challenges - such as statement, expression, sequence, selection process, loop process, function, program construct, data string manipulation, etc.