Lesson 1 Programming Concepts
Lesson 1 Programming Concepts
i. Constant
it is a variable once declared cannot change
ii. Literal
it is a value that is written into the code of a program
iii. Variable
It is a named storage location in the computer’s memory
When naming a variable in programming, there are several important rules to follow to ensure
your code is clear and error-free:
1. Start with a Letter or Underscore: Variable names must begin with a letter (A-Z or a-z)
or an underscore (_). They cannot start with a digit.
2. Use Alphanumeric Characters and Underscores: After the first character, variable
names can include letters, digits (0-9), and underscores. Special characters like @, #, %,
etc., are not allowed.
3. Case Sensitivity: Variable names are case-sensitive. For example, myVariable and
myvariable would be considered different variables.
4. No Spaces or Special Characters: Spaces and special characters (except underscores)
are not permitted in variable names.
5. Avoid Reserved Keywords: Do not use reserved words or keywords of the programming
language (like int, class, if, etc.) as variable names.
6. Descriptive Names: Use meaningful names that describe the purpose of the variable,
such as totalAmount or userName, to make your code more readable. iv. comment
Are short non executable statements that are included in the source code of a
program to make it more readable or to explain the purpose of the program
There are two types of comment
i. Execution time:- Applications that require quick response are best programmed in
machine code or assembly language. High-level languages are not suitable for such
application because, they take long to be translated & executed.
ii. Development time: - Development time is the time a programmer takes to write and run
a program. High-level languages are easy to read, understand and develop; hence, they
require less development time. Machine code & Assembly languages are relatively
difficult to read, understand and develop; hence, they are time-consuming.
iii. Popularity:- The language selected should be suitable and/or successful in the market
with respect to the problems to be solved.
iv. Documentation:- It should have accompanying documentation (descriptions) on how to
use the language or maintain the programs written in the language.
v. Maintenance:- Programs are developed to solve specific problems, and the problems
keep on changing; hence, the programs are also changed to perform the new functions.
vi. Program maintenance is the activity of incorporating more routines onto the
program, modifying the existing routines or removing the obsolete routines to make the
program adapt to functionally enhanced environment. The maintenance is made easier if
the language used is easy to read and understand.
vii. Availability of skilled programmers: - The language selected should have a pool of
readily available programmers to ease the programming activity, and reduce development
time.
1. Machine language
In machine language instruction are written in zeros and ones (0’s and 1’s) Machine
language has several notable disadvantages:
1. They are easily portable, i.e., they can be transferred between computers of different
families and run with little or no modification.
2. High-level language programs are short, and take shorter time to be translated.
3. They are easy to lean, understand and use.
4. They are easy to debug (correct/remove errors), & maintain.
5. High level language programs are easy to modify, and also to incorporate additional features
thus enhancing its functional capabilities.
6. They are ‘user-friendly’ & problem-oriented; hence, can be used to solve problems arising
from the real world.
7. They enable programmers to adapt easily to new hardware. This is because; they don’t have
to worry about the hardware design of the computer.
8. High-level language programs are self-documenting, i.e., the program statements displays the
transparency of purpose making the verification of the program easy.
9. High level languages are more flexible; hence, they enhance the creativity of the programmer
and increase his/her productivity in the workplace.
1. High-level languages are not machine-oriented; hence, they do not use of the CPU and
hardware facilities efficiently.
2. The languages are machine-independent, and cannot be used in programming the hardware
directly.
3. Each high-level language statement converts into several machine code instructions. This
means that, they use more storage space, and it also takes more time to run the program.
4. Their program statements are too general; hence, they execute slowly than their machine
code program equivalents.
5. They have to be interpreted or compiled to machine-readable form before the computer can
execute them.
An Assembler is a program that takes basic computer instructions and converts them into a
pattern of bits that the computer's processor can use to perform its basic operations. Some
people call these instructions assembler language and others use the term assembly language.
A virtual machine (VM) is a software program or operating system that not only exhibits
the behavior of a separate computer, but is also capable of performing tasks such as running
COMPILERS
Compiler is a special program that processes statements written in a particular programming
language and turns them into machine language or "code" that a computer's processor uses.
Typically, a programmer writes language statements in a language such as Pascal or C one line
at a time using an editor. It is a program translator that translates the instruction of a higher level
language to machine language. It is called compiler because it compiles machine language
instructions for every program instructions of higher level language.
The programs written by the programmer in higher level language is called source program.
After this program is converted to machine languages by the compiler it is called object
program.
Higher Level Language --> (Compile) ---> Program --> Machine Language Program A
compiler can translate only those source programs, which have been written, in that language
for which the compiler is meant for. For example FORTRAN compiler will not compile
source code written in COBOL language.
Object program generated by compiler is machine dependent. It means programs compiled
for one type of machine will not run in another type. Therefore every type of machine must
have its personal compiler for a particular language. Machine independence is achieved by
using one higher level language in different machines.
A compiler takes a program written in high-level language and converts it into an equivalent
program in machine language (translation).
Source program comp iler execution results of the programming
Interpreters
Interpreter, Computer language processor that translates a program line-by-line
(statementby-statement) and carries out the specified actions in sequence. It directly executes
the statements of a high-level language, just as if those statements were part of the instruction
set of the machine.
interpreter
Program statements result of the statement
Interpreter Compiler
Translates program one statement at a Scans the entire program and translates it as
time. a whole into machine code.
It takes less amount of time to analyze the It takes large amount of time to analyze the
source code but the overall execution time source code but the overall execution time is
is slower. comparatively faster.
Continues translating the program until the It generates the error message only after
first error is met, in which case it stops. scanning the whole program. Hence
debugging is comparatively hard.
Hence debugging is easy.
Programming language like Python, Ruby Programming language like C, C++ use
use interpreters. compilers.
Naturally enough, you should start with a clear idea of what you want the program to do.
Think in terms of the information your program needs, the feats of calculation and
manipulation the program needs to do, and the information the program should report back to
you. At this level of planning, you should be thinking in general terms, not in terms of some
In problem analysis the programmer identifies the input, process and program output
After you have a conceptual picture of what your program ought to do, you should decide
how the program will go about it. What should the user interface be like? How should the
program be organized? Who will the target user be? How much time do you have to
You also need to decide how to represent the data in the program and, possibly, in auxiliary
In a program
Design methodology
Flowchart: explain how to solve a problem using short statement and special symbols
Now that you have a clear design for your program, you can begin to implement it by writing
the code. That is, you translate your program design into the C language. Here is where you
really have to put your knowledge of C to work. You can sketch your ideas on paper, but
eventually you have to get your code into the computer. The mechanics of this process
depend on your programming environment. We'll present the details for some common
environments soon. In general, you use a text editor to create what is called a source code
The fact that your program runs is a good sign, but it's possible that it could run incorrectly.
Consequently, you should check to see that your program does what it is supposed to do.
There are several types of program testing, each serving a specific purpose to ensure the
quality and functionality of software. Here are some of the main types:
Unit Testing: Tests individual components or functions of a program to ensure they work
correctly in isolation1.
Integration Testing: Verifies that different modules or services within an application work
together as expected1.
System Testing: Tests the complete and integrated software to evaluate the system’s
compliance with its specified requirements2.
Acceptance Testing: Determines whether the overall system meets the business
requirements and is ready for deployment3.
Performance Testing: Assesses the speed, responsiveness, and stability of a system under a
particular workload.
Security Testing: Identifies vulnerabilities and ensures that the system protects data and
maintains functionality as intended4.
Usability Testing: Evaluates how user-friendly and intuitive the software is for end-users4.
Regression Testing: Ensures that new code changes do not adversely affect the existing
functionality of the software1.
Smoke Testing: A preliminary test to check the basic functionality of the application before
proceeding to more detailed testing2.
method
1. Direct implementation
2. Parallel implementation
3. Pilot implementation
4. Phased implementation
When you create a program for yourself or for someone else, that program could see
extensive use. If it does, you'll probably find reasons to make changes in it. Perhaps there is a
minor bug that shows up only when someone enters a name beginning with Zz, or you might
think of a better way to do something in the program. You could add a clever new feature.
You might adapt the program so that it runs on a different computer system. All these tasks
are greatly simplified if you document the program clearly and if you follow sound design
practices.