CMT 1208 –
COMPUTER PROGRAMMING
FOR TECHNOLOGY
CHAPTER 1 : INTRODUCTION TO PROGRAMMING
S.K.NISHADI PRASANGINI
TIME TABLE
Existing time Can change Students Location
Theory Mon 5.00- 6.00 Tue 3.00-4.00 All Convocation
Hall
Practical group Thu 4.00-6.00 --------------- BST first 70 CS Lab
1
Practical group Wed 3.00-5.00 --------------- BST and ENT ICT Lab
2 60
Practical group Mon 8.00-10.00 --------------- ENT others 60 ICT Lab
3
COURSE CAPSULE
• Introduction to Programming: Program development cycle, Listing major
tasks.
• Flowcharts and Design Structures: Basic design structures.
• Pseudocode: introduction to pseudocode, Advantages and disadvantages,
how to store and access data, Calculation symbols, Design structures in
pseudocode.
• Modules, Flags and Priming Read: Modularity, Flags and Switches, Prime
Reads and Loop Control;
• Introducing C: Structure of C program, Basic C commands, Loops, Symbolic
Constants, Character input and output, Logical AND & OR, Arrays and
Functions, Call by Reference and Call by Value.
COURSE CAPSULE (CONT..)
• Types, Operators and Expressions: Variables and Constants, Data Types,
Operators, Expressions.
• Control Flow: IF, Switches, Conditional Expressions, while, break and continue;
Functions and Program.
• Functions and Program Structure: Multi-file programs, Scoping, Recursion,
The C Pre-processor.
• Pointers and Arrays: Pointers and addresses, Organization of Memory,
Pointers and Arrays, Managing and manipulating memory, passing parameters
to C programs, Pointers to functions.
• Data Structures: Passing and returning structures, Pointers and structures,
Arrays of Structures
• Course Aim : To provide the basic knowledge and skills in computer programming.
• Course ILOs : At the end of the course, the student should be able to
Be able to implement, compile, test and run C programs.
Understand how to include arithmetic operators and constants in a C program.
Transform real world scenario into computer program
• Assessment Strategy:
Continuous assessment -40%
Assignment - 10%
Mid semester examination - 10%
Mini project - 20%
End semester examination -60%
Practical -20%
Theory -40%
Google Classroom Link : PP67YSF
Any Question ?
Contact : Nishadi Prasangini - [email protected]
INTRODUCTION
What is a Software?
What is a Program?
SOFTWARE
• A set of instructions that enables physical components of a
computer to work in a synchronize way is known as software .
• This set of instructions is often called a program.
• Computers cannot do any useful work without instructions from
software
COMPUTER SOFTWARE RELATIONSHIPS
User Interface Application Programs
User Interface Operating System
User Basic Input and Output Services (BIOS)
Interface • needed for a computer to boot up
Computer Hardware
WHAT IS A (PROGRAMMING)
LANGUAGE?
A sequence of instructions
An algorthm A program
(in human language) (in computer language)
• A program needs to be written in a language
• There are many programming languages
• Low-level, understandable by a computer
• High-level, needs a translator!
• C++ is a high level programming language
PROGRAMMING – WHY?
• Computers are used for many different purposes in many different situations.
• But, how can they be so versatile?
• Answer: They can be programmed
• The ability for a computer to be programmed allows it to do whatever their
programs tell them what to do.
• A program is a set of instructions that tell a computer what to do.
• A computer cannot do anything unless it has a program to tell it what to do.
• In this class, we will focus on writing these programs.
PROGRAMMING – WHAT?
• Programs are used to operate the components of a computer, solve problems
or satisfy a want/need.
• How long will it take me to get home if I drive x miles per hour?
• I want to be able to tell my friends what I am doing right now.
• Computer Programming is both an Art and a Science
• Every aspect of a program must be carefully designed
• As an art, programming takes creativity and problem solving.
• There is often no one correct way to solve a problem.
• As a science, there are formal and proven methods to go about creating a
programming.
PROGRAM DEVELOPMENT LIFE CYCLE
The program development process is part of the software lifecycle,
characterized by the following stages:
Requirements analysis
Design
Coding
Testing
Implementation and support
Documentation
REQUIREMENTS ANALYSIS
• An accurate and complete set of client and user requirements
is produced to determine the characteristics of an acceptable
solution
REQUIREMENTS ANALYSIS
(CONT’D)
The requirements analysis specification will contain:
• the proposed system or solution, which has been agreed by the
client and developer
• a list of existing tools, new tools, required facilities and people
available for developing the solution
• a schedule for the next stages of the project, including the
deliverables for each stage
DESIGN STAGE
• Use of proper design techniques to illustrate the program specification in
a systematic way
• Representing the tasks required in the program specification showing all
input, processing and output requirements
• Examples :
• Flowchart
• Pseudocode
• Hierarchy Charts
CODING STAGE
• Produce the programs that will make up the system
• Translation of design into programming language code
e.g. C, C++, Pascal, Qbasic
• Complete when all code is written and documented, and compiles
without any errors
TESTING STAGE
• Debugging – Done by Development Team –
The task of finding and removing errors/bugs from the program.
• Testing – Done by Testing Team –
The task of locating and identifying of bugs/errors included
TESTING STAGE (CONT’D)
• When the program is completed and all separate modules have been
tested, a full test of the program is performed
• any errors in the program will be corrected and the test repeated
• Types of Tests:
• Alpha test
• test of the finished application completed internally
• Beta test
• tested externally
IMPLEMENTATION AND
SUPPORT
• When all the previous stages have been completed satisfactorily, the
system is ready for implementation
• Program is transferred to the user’s machine and made to work.
• 3 strategies:
• The new program may run concurrently with the old one
• it may completely replaced the old one or
• It may phased in gradually
IMPLEMENTATION AND SUPPORT (CONT’D)
• Once the program is installed and operated, it will be monitored for
some time to ensure that program is error-free. –
Support/Maintenance Stage
• Maintenance includes
error fixing,
updates and
modifications.
DOCUMENTATION STAGE
• All processes in all stages during the system development must be
documented/written down.
• This documentation is vital for future reference/for future maintenance
of the program.
CHARACTERISTICS OF A GOOD PROGRAM
• Correctness – fulfilling user requirements
• Reliability – it produces correct output and validates input data to avoid
program crash
• Portability – easily installed from one machine to another with minimal
modification
• Maintainability – easily followed and modified, not only to the
programmer who wrote it
• Readability – clearly documented
• Use of resources – fast in processing, uses minimum storage space and
able to run on existing hardware.
TYPES OF ERRORS
Syntax – error relating to the programming language used
Logical – error in programming logic
Run-time/execution – error that appears after you compile and run
your code
SUMMARY
Program Development Life Cycle: Types of Errors
Requirements analysis Syntax
Design Logical
Coding Run-Time
Testing
Implementation and support
Documentation
Levels of programming language
• Machine binary language: unintelligible
• Low-level assembly language
• Mnemonic names for machine operations
• Explicit manipulation of memory addresses
• Machine-dependent
• High-level language
• Readable
• Machine-independent
AN EXAMPLE:
Machine binary language Low-level assembly High-level
HOW TO TRANSLATE?
A program written in high-level programming language
(for example, C++ program)
COMPILER (for example, Visual C++)
A low-level (machine language) program that is
understandable by a computer (for example, a PC)
EXAMPLES OF COMPILERS:
• MICROSOFT VISUAL C++, ECLIPSE, G++
TRANSLATION SYSTEM
• Machine binary language: unintelligible
• Low-level assembly language
• Mnemonic names for machine operations
• Explicit manipulation of memory addresses
• Machine-dependent
• High-level language
• Readable
• Machine-independent
SOFTWARE DEVELOPMENT
• Major activities
Editing (writing the program)
Compiling (creates .Obj file)
Linking with compiled files (creates .Exe file)
S ourc e Program
• Object files
C om pile
• Library modules
Library routines
Loading and executing E dit Link
Testing the program O ther objec t files
Think Load
E xecute
INTEGRATED
DEVELOPMENT ENVIRONMENTS
• Combine all of the capabilities that a programmer would want
while developing software (VC++ 2008, eclipse)
Editor
Compiler
Linker
Loader
Debugger
Viewer
OUR FIRST PROGRAM
// a simple program
#include <iostream> Comments
using namespace std;
int main() {
Function cout << "Hello world!" << endl;
named return 0;
main() }
indicates
start of
program
Ends execution Print
of main() which ends program statement