Fundamentals of Computer Programming
Part Three - Challenge #02


What Computer Programmers Do?
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 which are listed below.

Computer programmers typically do the following:

  • Write programs in a variety of computer languages
  • Update and expand existing programs
  • Test programs for errors and fix the faulty lines of computer code
  • Create and test code using integrated development environment (IDE) tool sets
  • Use code libraries, which are collections of independent lines of code, to simplify the writing

What Software Developers Do?
Software developers are the creative minds behind computer programs. Some develop the applications that allow people to do specific tasks on a computer or another device. Others develop the underlying systems that run the devices or that control networks.

Many software developers work for firms that deal in computer systems design and related services or for software publishers.

Here is some information about these job roles in the United States:

If you noticed a decline in the demand for computer programmers from the above web site, this is misleading. For example, many jobs exist that assume knowledge of and some experience with computer programming and/or software development as a prerequisite for the job - such as an IT Consultant, etc.

While you have successfully demonstrated the ability to maintain an existing COBOL computer program in the final challenge of Part 2, fundamentals of computer programming apply to all computer programming languages. Experienced computer programmers know the learning curve dramatically shinks with each new computer language because the fundamentals are the same. What is different is variations in programming language syntax and how to execute the program on the target operating system.

Fundamental to learning how to read, change, and write a computer program using a new programming language is the familiarity with the programming language syntax and the target operating system environment procedures used to execute the program.

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
  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 +
  • DIVIDE /
    Relational Operators are:
  • EQUAL =
    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.
  • 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 ()
      THEN ;
      ELSE ;
     IF (A > B)
      THEN Print A + "is bigger";
      ELSE Print B + "is bigger";
  • 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 ()
        DO ();

       A = 1;
       WHILE (A < 5)
        DO Print A;
         A = A + 1;
    • 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 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 next several challenges will expose you to common programming languages.

          So, about now you might be asking, "Is one programming language enough to get a computer to do what I want it to do?" Programming languages have strengths and weaknesses as well as attributes that make a programming language the best fit for a specific task in a specific operating system. The analogy is, "if you only have a hammer, then everything looks like a nail". These challenges expose you to common programming languages which are effective tools of the IT business application architecture trade.

          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.

          An extremely flexible z/OS computer programming language, REXX, will be used to demonstrate the above computer programming language fundamentals. The challenge is to change the sample computer program as instructed.

          Enough preparation reading. Time to do a very simple programming language challenge.


          Edit hlq.SOURCE

          s xyz to create and edit this new member name

          copy 'zos.mtm2017.public.source(xyz)'
          Note: Enter hilite rexx to hilite the rexx reserved words

          You are seeing REXX programming language code.

          F3 to return to hlq.SOURCE directory list

          Many methods exist for executing REXX program in the z/OS environment.
            Enter ex to the left of member name xyz to execute the REXX programming language code.

          The XYZ REXX program writes helpful messages to your display.

          Edit hlq.SOURCE member name xyz

          You only need to focus on REXX Program lines 2 thru 10.

          Note: Replace ? with the correct REXX programming language arithmetic operators.

          Execute the REXX program until the program writes "The program generated a valid numeric number" message to your display.

          The REXX program will write the number from the program arithmetic operations to hlq.P3.OUTPUT(#02) following that message.

          If you want a simple explanation of the basic REXX program constructs, click on the following URLs:
          Learn REXX
          REXX Programming Introduction

          Next: Challenge #03