Unique Programming Language Fundamentals: A Step by Step Easy to Understand Tutorial in 2023

Programming Language
  • A programming language is used to direct a computer to accomplish a specific set of steps which results to a desired output.
  • A computer can understand only its own native code i.e. the machine code.
  • This is the lowest level of programming language in which we can write program.
  • The very first program were written in pure binary notation where both data and instructions, had to be encoded in strings of 1s and 0s.
  • A low- level language corresponds closely to the machine code so that a single low-level language instruction translates to a single machine language instruction.
  • Programming in machine language needs to remember all binary codes and hence it is difficult for the human programmer.
  • The middle-level and high-level programming language translates an instruction into a series of machine- language instruction.
  • The levels are decided on the basis of how closely they can be said to look like machine code.
  • A high level programming languages allows faster development of larger programs. It saves programmers time.
  • The levels can be categorized as:
    • Binary Programming
    • Assembly Programming
    • Procedure Oriented Programming
    • Structured Programming Language
    • Object Oriented Programming
    • Visual Programming
  • The assembly language made programming easier than machine language.
  • In assembly language, the pneumonic abbreviations were used to represent several machine language instructions.
  • The assembly language was machine dependent.
  • Before execution of the assembly language, it needs to convert to machine language and this is done by a special program know as Assembler.
  • High level languages use word and verbs to command the computer.
  • In the high level coding makes programming easier.
  • High level language uses either compiler or an interpreter to translate the entire source code before execution.
  • Interpreter translates source code program one line at a time whereas compiler translates complete source code at a time.
  • Hence, we can say that interpreter is more interactive than compilers.
  • Compiler languages are the high-level language which are equivalent of assembly language.
  • The compiled machine code less efficient than the code produced using assembly language.
  • The compiled code is stored separately from source code and can be run at any time.
  • Interpreter language is also a high level language.
  • Interpreter program resides in memory and directly executes the high level program without preliminary translation to machine code.
  • The structured programming language introduces some programming principles like top-down design and modularity.
  • Following figure show language is how far from the hardware.
OO and Visual Language1

Compiler

  • In programming language, computer do not understand High Level Language(HLL).
  • A source file (.c program) cannot execute directly.
  • To run program,it must be translated into binary numbers understandable to CPU.
  • Hence compilation process produces an intermediate object file(.obj)
  • A compiler is a program that translates HLL into the machine language of a computer.
  • Besides program translation, the compiler performs another very important function i.e. error detection capability.
  • The important tasks of compiler are:
    1. Translation the HLL programs input into an equivalent machine language program.
    2. Providing diagnostic message wherever specifications of the HLL are violated by the programmer.
  • HLL permits the program to declare and use data structures like arrays, stacks, tables, records,list. For this, compiler has to develop and use the storage mapping to access the actual storage cells allocated to various elements of the data structures.

Linking

  • In programming language C contains many inbuilt-functions(library functions) which come with language.
  • These library functions are written by the compiler manufacturer to perform variety of tasks.
  • And hence it is necessary to link our program to such library files.
  • After linking, it creates an executable file with extension .exe
  • Linking is the final state of compilation. It takes one or more object files or libraries as input and combines them to produce a single executable file.
  • During linking, linker resolves references to external symbols, assigns final address to functions and variables and revises code and data reflect new addresses.
  • Linking may be statically or dynamically.
  • Statically linked means that the program and particular library that its linked against are combined together by the linker at link time.
  • Dynamically linked means that linker places information into the executable that tells the loader which share object module the code is in and which runtime linker should be used to find and bind the references.

Logic Development Tools Used in the Programming Language: Algorithms & Flowchart

Algorithm:
Algorithm is a program logic development tool and is programming language independent. Algorithm is defined as a finite set of instructions which, if following accomplish a particular task. In addition every algorithm must satisfy the following criteria:
1. Input there are zero or more quantities which are externally supplied;
2. Output at least one quantity is produced;
3. Definiteness each instruction must be clear and unambiguous.
4. Effectiveness every instruction must be sufficiently basic that it can in principle to carry out by a person using only pencil and paper. It is not enough that each operation is definite as in (3), but it must also be feasible.

Sub-Algorithm:
Sub-algorithm is a complete and independently defined algorithmic module, which is used or invoked or called by some main algorithm or by some other sub-algorithm.

Sub-algorithm receives come values, called arguments, from a calling algorithm; performs computation; and then sends back the result to the calling algorithm.

Sub-algorithm is defined independently so that may be called by many different algorithms or may be called at different times in the same algorithm.

Difference Between Algorithm and Sub-Algorithm

  • Algorithm is defined as a finite set of instructions which, if following accomplish a particular task.
  • Sub-algorithm is a complete and independently defined algorithmic module, which is used or invoked or called by some main algorithm or by some other sub-algorithm.
  • The main difference between the format of algorithm and sub-algorithm that the argument of sub-algorithm are used to transmit data between the sub-algorithm and calling algorithm.
  • Another difference is that sub-algorithm has Return statement rather than an Exit statement.
  • Sub-algorithm may be a function sub-algorithm or procedure sub-algorithm.
  • Function sub-algorithm returns only single value to calling algorithm whereas procedure sub-algorithm may sen back more than one value.

Flowchart

  • Flowchart is a program logic development tool and is programming language independent.
  • Flowchart is a pictorial representation of algorithm.
  • This is most commonly used tool as the pictures are more understandable than the text.
  • Flowchart is two dimensional and generally logic flows from the top to bottom.
  • Flowchart helps to easily understand data and control flow.
  • If the flowchart is too big to fit on a page, connectors are used to connect one part to another.
  • Standard program flowchart symbols are –
Standard Flowchart Symbols
  • “Terminal” i.e. Oval symbol is used for start and end point. For a good program, logic should be a single start and single end point.
  • “Input/Output”symbol is used when user has to key-in some data from the standard input device(keyboard) or to display some data or information on to monitor.
  • “Process” is used to represent the process steps defined in algorithm.
  • “Decision” i.e. Diamond symbol is used when CPU takes any decision depending on specified condition(logical expression). Depending on the evaluation of the condition,flow of control may change.
  • “Flow lines” i.e. Arrows symbol represents the control flow in the flowchart. The arrow head indicates the direction of flow.
  • “Connector” i.e. Circle symbol is used to connect the symbols on different pages.

Compound Statements and Block Structure

  • The term “block structure” refers to different features in different language.
  • In any language, there are essentially three features for which this term is commonly used-
    1. Compound Statement
    2. Block
    3. Nested procedure definitions
  • Compound statement is a statement composed of a list of statements, delimited as a compound by some sort of bracket.
  • Compound statement do not permit the introduction of new identifiers. It serve the sole purpose of statement grouping.
  • Blocks combine compound statements with the declaration of new identifiers.
  • Block restricts the visibility of theses identifiers that, they may only be used inside the block.
  • Procedures are essentially blocks with formal parameters.
  • Another difference between blocks and procedures is that blocks are only executed where they are defined, but procedures may be invoked within any scope where their names are visible.
  • C is a block structured language.
  • A block is a sequence of statements.
  • In C, curly braces {….} defines a block.
  • Blocks can be nested i.e. a block can contain another block.
  • In C, block can declare a variable immediately after the opening of curly brace { in any block.

Computer Program

  • As per Google, A computer program is a sequence or set of instructions in a programming language for a computer to execute. Computer programs are one component of software, which also includes documentation and other intangible components. A computer program in its human-readable form is called source code
  • Program is a set of instruction given to computer for solving any real life problem or mathematical model using programming language.
  • When a problem is to be solved, two question arise.
    1. What to do?
    2. How to do?
  • Actually, problem solving process has following 6 steps:
    a. Defining the problem
    b. Problem Analysis
    c. Solution Designing
    d. Program Coding
    e. Program Testing
    f. Program Maintenance
  • Basically there are three programming structures.
    a. Sequence
    b. Selection
    c. Iteration
  • Sequence means that there is no intervening control structure and control flows normally from one step to next in sequence.
  • Selection is applicable when more than one options are available and the user has to selection appropriate one on the basis of some criterion.
  • Selection refers to decision making process and it may –
    a. One way selection (no alternative available)
    b. Two way selection (only one alternative available)
    c. Multi way selection (more than one alternatives available)
  • Iteration is a loop structure that creates an iterative structure.
  • Iteration means repetition of the same logic for execution till the specified condition met.
  • Iteration saves the time and energy of programmer for writing same statements again and again.
  • Iteration may be
    a) Pre-tested (criteria is checked in beginning)
    b) Post-tested (criteria is checked at end)
  • A computer program consists of following parts:
    1. Data items definition
    2. Initialization
    3. Input statement
    4. Assignment statements
    5. Conditional statements
    6. Iterative structures
    7. Control transfer statements
    8. Output statements
    9. Comments whenever necessary
  • Steps for program development are:
    4