ZeePedia buy college essays online

Introduction to Programming

<<< Previous System Software, Application Software, C language Next >>>
CS201 ­ Introduction to Programming
Lecture Handout
Introduction to programming
Lecture No. 2
Reading Material
Deitel & Deitel ­ C++ How to Program
chapter 1
1.2, 1.3, 1.4, 1.6, 1.7
1.11, 1.12, 1.13
Software Categories
o System Software
o Application Software
History of C language
Development Environment of `C'
Software Categories
Software is categorized into two main categories
System Software
Application Software
Page 7
CS201 ­ Introduction to Programming
System Software
The system software controls the computer. It communicates with computer's hardware
(key board, mouse, modem, sound card etc) and controls different aspects of operations.
Sub categories of system software are:
o Operating system
o Device drivers
o Utilities
Operating system
An operating system (sometimes abbreviated as "OS") is the program that manages all
the other programs in a computer. It is a integrated collection of routines that service the
sequencing and processing of programs by a computer. Note: An operating system may
provide many services, such as resource allocation, scheduling, input/output control, and
data management.
"Operating system is the software responsible for controlling the allocation and usage of hardware
resources such as memory, central processing unit (CPU) time, disk space, and peripheral devices. The
Page 8
CS201 ­ Introduction to Programming
operating system is the foundation on which applications, such as word processing and spreadsheet
programs, are built. (Microsoft)"
Device drivers
The device driver software is used to communicate between the devices and the
computer. We have monitor, keyboard and mouse attached to almost all PC's; if we look
at the properties of these devices we will see that the operating system has installed
special software to control these devices. This piece of software is called device driver
software. When we attach a new device with the computer, we need software to
communicate with this device. These kinds of software are known as device drivers e.g.
CD Rom driver, Sound Card driver and Modem driver. Normally manufacturer of the
device provide the device driver software with the device. For scanners to work properly
with the computers we install the device driver of the scanner. Nowadays if you have
seen a scanner, it comes with TWAIN Drivers. TWAIN stands for Technology Without
An Interesting Name.
Utility Software
Utility software is a program that performs a very specific task, usually related to
managing system resources. You would have noticed a utility of Disk Compression.
Whenever you write a file and save it to the disk, Compression Utility compresses the file
(reduce the file size) and write it to the disk and when you request this file from the disk,
the compression utility uncompressed the file and shows its contents. Similarly there is
another utility, Disk Defragmentation which is used to defragment the disk. The data is
stored on the disks in chunks, so if we are using several files and are making changes to
these files then the different portions of file are saved on different locations on the disk.
These chunks are linked and the operating system knows how to read the contents of file
from the disk combining all the chunks. Similarly when we delete a file then the place
where that file was stored on the disk is emptied and is available now to store other files.
As the time goes on, we have a lot of empty and used pieces on the disk. In such situation
we say that the disk is fragmented now. If we remove this fragmentation the chunks of
data on the disk will be stored close to each other and thus reading of data will be faster.
For the purpose of removing fragmentation on the disk the Defragmentation utility is
The compilers and interpreters also belong to the System Software category.
Application software
A program or group of programs designed for end users. For example a program for
Accounting, Payroll, Inventory Control System, and guided system for planes. GPS
(global positioning system), another application software, is being used in vehicles,
which through satellite determines the geographical position of the vehicle
Page 9
CS201 ­ Introduction to Programming
History of C language
The C language was developed in late 60's and early 70's, in Bell Laboratories. In those
days BCPL and B languages were developed there. The BCPL language was developed
in 1967 by Martin Richards as a language for writing operating systems software and
compilers. In 1970 Ken Thompson used B language to create early versions of the UNIX
operating system at Bell Laboratories. Thus both the languages were being used to
develop various system software even compilers. Both BCPL and B were `type less'
languages, every data item occupied one `word' in memory and the burden of treating a
data item as a whole number or real number, for example was the responsibility of the
Dennis Ritchie developed a general purpose language, called C language, by using
different features of BCPL and B languages. C uses many important concepts of BCPL
and B while adding data typing and other features. In the start C became widely known as
the development language of the UNIX operating system, and the UNIX operating
system was written by using this C language. The C language is so powerful that the
compiler of C and other various operating systems are written in C. C language has
almost unlimited powers to do with computers. You can program to turn on or off any
device of computer. You can do a lot to hard disk and other peripherals. It is very easy to
write a program in C that stops the running of computer. So be careful while
programming in C.
The C language and UNIX operating system widely spread in educational and research
institutions. There was C and UNIX everywhere. Due to the wide spread of C, different
researchers started to add their features in the language. And thus different variations in C
came into existence. Many universities developed their own C by adding different
features to the C language developed by Ritchie. These variations led to the need of a
standard version of C. In 1983 a technical committee was created under the American
National Standards Committee on Computer and Information Processing to provide an
unambiguous and machine-independent definition of the language. In 1989 the standard
was approved. ANSI cooperated with the International Standard Organization (ISO) to
standardize C worldwide.
Tools of the trade
As programmer we need different tools to develop a program. These tools are needed for
the life cycle of programs
First of all we need a tool for writing the code of a program. For this purpose we used
Editors in which we write our code. We can use word processor too for this, but word
processors have many other features like bold the text, italic, coloring the text etc, so
when we save a file written in a word processor, lot of other information including the
text is saved on the disk. For programming purposes we don't need these things we only
need simple text. Text editors are such editors which save only the text which we type. So
for programming we will be using a text editor
Page 10
CS201 ­ Introduction to Programming
Compiler and Interpreter
As we write the code in English and we know that computers can understand only 0s and
1s. So we need a translator which translates the code of our program into machine
language. There are two kinds of translators which are known as Interpreter and
Compilers. These translators translate our program which is written in C-Language into
Machine language. Interpreters translates the program line by line meaning it reads one
line of program and translates it, then it reads second line, translate it and so on. The
benefit of it is that we get the errors as we go along and it is very easy to correct the
errors. The drawback of the interpreter is that the program executes slowly as the
interpreter translates the program line by line. Another drawback is that as interpreters are
reading the program line by line so they cannot get the overall picture of the program
hence cannot optimize the program making it efficient.
Compilers also translate the English like language (Code written in C) into a language
(Machine language) which computers can understand. The Compiler read the whole
program and translates it into machine language completely. The difference between
interpreter and compiler is that compiler will stop translating if it finds an error and there
will be no executable code generated whereas Interpreter will execute all the lines before
error and will stop at the line which contains the error. So Compiler needs syntactically
correct program to produce an executable code. We will be using compiler in our course
Another important tool is Debugger. Every programmer should be familiar with it.
Debugger is used to debug the program i.e. to correct the logical errors. Using debugger
we can control our program while it is running. We can stop the execution of our
program at some point and can check the values in different variables, can change these
values etc. In this way we can trace the logical errors in our program and can see whether
our program is producing the correct results. This tool is very powerful, so it is complex
Most of the time our program is using different routines and functions that are located in
different files, hence it needs the executable code of those routines/functions. Linker is a
tool which performs this job, it checks our program and includes all those routines or
functions which we are using in our program to make a standalone executable code and
this process is called Linking
After a executable program is linked and saved on the disk and it is ready for execution.
We need another process which loads the program into memory and then instruct the
processor to start the execution of the program from the first instruction (the starting
point of every C program is from the main function). This processor is known as loader.
Page 11
CS201 ­ Introduction to Programming
Linker and loaders are the part of development environment. These are part of system
The following figure represents a graphical explanation of all the steps involved in
writing and executing a program.
Preprocessor program
processes the code.
Compiler creates object
code and stores
it on disk.
Linker links the object
code with the libraries
Primary Memory
Loader puts program
in memory.
Primary Memory
CPU takes each
instruction and
executes it, possibly
storing new data
values as the
program executes.
Page 12
Table of Contents:
  1. What is programming
  2. System Software, Application Software, C language
  3. C language: Variables, Data Types, Arithmetic Operators, Precedence of Operators
  4. C++: Examples of Expressions, Use of Operators
  5. Flow Charting, if/else structure, Logical Operators
  6. Repetition Structure (Loop), Overflow Condition, Infinite Loop, Properties of While loop, Flow Chart
  7. Do-While Statement, for Statement, Increment/decrement Operators
  8. Switch Statement, Break Statement, Continue Statement, Rules for structured Programming/Flow Charting
  9. Functions in C: Structure of a Function, Declaration and Definition of a Function
  10. Header Files, Scope of Identifiers, Functions, Call by Value, Call by Reference
  11. Arrays: Initialization of Arrays, Copying Arrays, Linear Search
  12. Character Arrays: Arrays Comparisonm, Sorting Arrays Searching arrays, Functions arrays, Multidimensional Arrays
  13. Array Manipulation, Real World Problem and Design Recipe
  14. Pointers: Declaration of Pointers, Bubble Sort Example, Pointers and Call By Reference
  15. Introduction, Relationship between Pointers and Arrays, Pointer Expressions and Arithmetic, Pointers Comparison, Pointer, String and Arrays
  16. Multi-dimensional Arrays, Pointers to Pointers, Command-line Arguments
  17. String Handling, String Manipulation Functions, Character Handling Functions, String Conversion Functions
  18. Files: Text File Handling, Output File Handling
  19. Sequential Access Files, Random Access Files, Setting the Position in a File, seekg() and tellg() Functions
  20. Structures, Declaration of a Structure, Initializing Structures, Functions and structures, Arrays of structures, sizeof operator
  21. Bit Manipulation Operators, AND Operator, OR Operator, Exclusive OR Operator, NOT Operator Bit Flags Masking Unsigned Integers
  22. Bitwise Manipulation and Assignment Operator, Programming Constructs
  23. Pre-processor, include directive, define directive, Other Preprocessor Directives, Macros
  24. Dynamic Memory Allocation, calloc, malloc, realloc Function, Dangling Pointers
  25. History of C/C++, Structured Programming, Default Function Arguments
  26. Classes and Objects, Structure of a class, Constructor
  27. Classes And Objects, Types of Constructors, Utility Functions, Destructors
  28. Memory Allocation in C++, Operator and Classes, Structures, Function in C++,
  29. Declaration of Friend Functions, Friend Classes
  30. Difference Between References and Pointers, Dangling References
  31. Operator Overloading, Non-member Operator Functions
  32. Overloading Minus Operator, Operators with Date Class, Unary Operators
  33. Assignment Operator, Self Assignmentm, Pointer, Conversions
  34. Dynamic Arrays of Objects, Overloading new and delete Operators
  35. Source and Destination of streams, Formatted Input and Output, Buffered Input/Output
  36. Stream Manipulations, Manipulators, Non Parameterized Manipulators, Formatting Manipulation
  37. Overloading Insertion and Extraction Operators
  38. User Defined Manipulator, Static keyword, Static Objects
  39. Pointers, References, Call by Value, Call by Reference, Dynamic Memory Allocation
  40. Advantages of Objects as Class Members, Structures as Class Members
  41. Overloading Template Functions, Template Functions and Objects
  42. Class Templates and Nontype Parameters, Templates and Static Members
  43. Matrices, Design Recipe, Problem Analysis, Design Issues and Class Interface
  44. Matrix Constructor, Matrix Class, Utility Functions of Matrix, Input, Transpose Function
  45. Operator Functions: Assignment, Addition, Plus-equal, Overloaded Plus, Minus, Multiplication, Insertion and Extraction