CHIP - Programming Concepts
CHIP - Programming Concepts
18 October 2021
▶ Application Software
▶ Utilities
– Interpreters
– Virus Scanners
– Disk Maintenance
– Compiled programs
– Interpreted programs
Compiler Interpreter
Executable
▶ Object Oriented
– Impure (C++)
– Makes use of objects but not all oops concepts can be used
– coded by a programmer
– in a particular sequence
– Data
• Concept of Type
• Storage Class
– Executable Statements
– Digits
– Logical
– Conditional
– Set, storing variables of the same data type referred with a single variable name
– Directives
– Declarative statements
– Executable statements
• Expression statements
• Assignment statements
▶ Application
▶ Scope of a Variable
– Local (defined in a function/block)
– Global (defined outside a function)
▶ Lifetime of a Variable
– Local variables – same as the life of function
– Global variables – same as the life of application
– Static variables – same as the life of application but scope is like a local variable (allowed only
by some languages e.g. C++)
▶ Parameters behave as local variables (allocated on stack)
▶ All programs should include a comment block at or near the beginning of the program
▶ Be consistent! Stick to a method for variable naming or indenting throughout your program
▶ Subroutines should be short enough so that reader can grasp their meaning as a unit
▶ Every subroutine should be preceded by a comment describing its purpose and use
▶ Functions should affect precisely one value - the function's return value
▶ Pick identifiers (i.e. names for variables, functions, records, etc.) that communicate the named
object's purpose to the reader
▶ Be consistent about the use of local variables with the same name throughout the program
▶ Carefully consider every number that is typed in the code, and substitute a name for it (unless
you have a reason not to do so)
– In case of most IDE's, whenever an error is detected during the execution of a program,
program execution stops and an error message is printed.
– The execution context is that of the program unit (procedure, function, or main program) in
which the error occurred.
– When execution is interrupted, a current-line indicator is placed next to the line that will be
executed when processing resumes.
– To understand what is happening during program execution, consider setting breakpoint and
stepping through the code
▶ As an example:
– If an error occurs because an undefined variable is referenced,
– you can simply define the variable at the command prompt and then continue execution.
– Of course, this is a temporary solution. You should still edit the program file to fix the
problem permanently.
▶ Some languages also allow creation of user-defined types - UDFs (struct, class, record..)
struct Employee
{
char name[30];
int age;
float salary;
};
Data Structure
Linear Non-Linear
Stack Queue
Has linear [unique] relationship between Does not have the linear relationship between
predecessor and successor predecessor and successor
– Use nodes which contain data and pointer to the next node in memory
Head
– Items can be removed from the same end from where they are added
Current TOP
Item2
Item1
– Items can be removed from front while they are added from the back
– Can be Circular
front
Item1 Item2
back
root
Item1 Item2
Item3 Item4
– While tree has single path from root to any node, graph can have multiple paths from one
node to another
Item5
Item1 Item2
Item4 Item3
▶ An algorithm is
– A procedure (a finite set of well-defined instructions) for accomplishing some task which,
given an initial state, will terminate in a defined end-state
• In order to carry out a specified task (calculating employee pay checks, printing students
report cards.)
– Human languages
– Pseudo code
– Flowcharts
– Programming languages
▶ Human languages
– A language that is spoken, written, or signed (visually or tactilely) by humans for general-
purpose communication
▶ Pseudo code
▶ Flowchart
▶ Sequential control is indicated by writing one action after another, each action on a line by itself,
and all actions aligned with the same indent. The actions are performed in the sequence (top to
bottom) that they are written.
▶ Example
▶ Example
INCREMENT personCount
CALL employeeList.getPerson with personCount
ENDWHILE
▶ Binary choice on a given Boolean condition is indicated by the use of four keywords: IF, THEN,
ELSE, and ENDIF
▶ Example
▶ This loop is similar to the WHILE loop except that the test is performed at the bottom of the loop
instead of at the top. Two keywords, REPEAT and UNTIL are used.
▶ General form:
REPEAT
sequence
UNTIL condition
▶ Example
CASE grade OF
A : points = 4
B : points = 3
C : points = 2
D : points = 1
F : points = 0
ENDCASE
▶ Example
FOR X = 1 to 10
FOR Y = 1 to 10
IF gameBoard[X][Y] = 0
Do nothing
ELSE
CALL theCall(X, Y) (recursive method)
increment counter
END IF
END FOR
END FOR
Set moveCount to 1
FOR each row on the board
FOR each column on the board
IF gameBoard position (row, column) is occupied THEN
CALL findAdjacentTiles with row, column
INCREMENT moveCount
END IF
END FOR
END FOR
INPUT Y
a wavy base;
Pay slip
▶ A manual input is represented by rectangle,
with the top irregularly sloping up from left to
right. E.g. data-entry from a form; Enter P.O.
Start
READ N
M=1, F=1
F=F*M
No
M=M+1 IS M=N?
Yes
PRINT F End
▶ A game of guessing random number generated by the computer in a finite number of attempts
▶ Unit of storage
– Allocation of a memory buffer which acts as a temporary area between the program and the
file on the disk
▶ Methods of reading/writing
– Text Files
• Character-by-character
• Line-by-line
• Entire contents
– Binary Files
• Byte-by-byte
• Block (record)-by-block
▶ A dedicated program called Database Management System (DBMS) takes care of data storage
and retrieval
▶ Applications communicate with DBMS in a standard way to work with data without worrying
about the names and location of the files containing actual data
▶ Types of DBMS
Atos, the Atos logo, Atos|Syntel are registered trademarks of the Atos group. © 2021
Atos. Confidential information owned by Atos, to be used by the recipient only. This
document, or any part of it, may not be reproduced, copied, circulated and/or distributed
nor quoted without prior written approval from Atos.