CS110 - Computer Programming
CS110 - Computer Programming
[email protected]
Objective of the Course:
●Decision making and Looping: for, while, do-while, nested loop, jumps in loops. 5hrs
●Structures and Unions: Introduction, structure and array, structure and function,
nesting of structures, Bitfields and Unions. 4 hrs
Course Coverage
●Pointers in C: Introduction, operations. 3 hrs
●File management in C-types of files, file modes and file functions, command line
arguments. 3 hrs
● Arrays 3
● Strings 3
● Pointers 3
Speed
● computers can perform 100 million computations in one second. Carry out calculations
that take a lot of time in seconds.
● The speed of computers are measured in terms of microseconds, Nano seconds and
even in Pico seconds.
Accuracy
● The computer is 100% accurate and capable to perform arithmetical calculation and
logic operations with same accuracy.
● The accuracy of a computer is Illustrated well by the term GIGO; i.e. Garbage In
Garbage Out.
Continued…..
Diligence:
Versatility:
● Computers are versatile machines - capable of performing any task as long as it can
be broken down into a series of logical steps.
● The presence of computers can be seen in almost every sphere – Railway/Air
Continued…..
Storage Capacity/Memory:
Automation:
CPU
Input Device ALU CU Output Device
■Examples of basic operation: adding two numbers, testing to see if two numbers are
equal.
The von Neumann architecture
●Main memory (called RAM for Random Access Memory): stores
programs and data.
■Mouse
■Trackball
■Touchpad
■Joystick
○Touchscreen
○Scanner
○Mic
○Camera
Output Devices
●Output devices show you the results of
processing data
●Monitor
■Printer
■Plotter
■Speaker
Speaker
Plotter
Processing Hardware
●The motherboard is the main
electronic component of the computer
●The microprocessor/processor is
one of the most important pieces of
processing hardware on the
motherboard.
Memory
Primary Memory
●Virtual memory
Continued….
SRAM-Static RAM
●An executable file contains the instructions that tell a computer how to
perform a specific task
●Hard Disks
○DVD
○CD-RW
○CD-ROM
○DVD-R
○DVD-RW
○BD
Storage Media
●Flash memory
○Solid state storage
● Storage/Memory
PRIMARY MEMORY
Primary Memory vs Secondary Memory
● Fast ● Slow
● Expensive ● Cheap
● Low capacity ● Large capacity
● Works directly with the processor ● Not connected directly to the
processor
Memory Hierarchy
Continued….
1. Internal register:
● Internal register in a CPU is used for holding variables and temporary results.
● Internal registers have a very small storage and they can be accessed instantly
2) Cache:
● Cache is used by the CPU for memory which is being accessed over and over again.
● Instead of pulling it every time from the main memory, it is put in cache for fast access.
● It is also a smaller memory, however, larger than internal register.
4) Secondary Storage
Cache memory
Parts of A Computer System
The major components of a computer system are:
● Hardware
● Software
● User
● Data
Data:
o Input given by user called data. That may contain a number ,text ,video ,audio etc.
o To process data, computer must be given an appropriate set of instructions called program.
o The processed data called information.
o These instructions are entered into computer and stored in a portion of the computer’s memory.
Continued…
Hardware:
● Computer hardware is any physical device used in or with your machine. Eg-mouse , keyboard
● The processor, main memory, secondary memory, power supply, and supporting hardware are
housed in a metal case.
● CPU contains motherboard which is the main circuitry to the system.
43
Classification of Hardware
1. Keyboard
●Keyboard is a primary input device of he computer.
●PS/2 Keyboard
track
sector
head
60
61
Hard Disk Connectors
Parallel Connector
for
ATA
Serial-ATA (SATA)
Connector
62
63
4. Optical Media
64
Optical Discs:
Compact Disk (CD) can store 650MB to 800MB of
information and data. CD-ROM (CD-R) (Read Only
Memory) can only read data from a CD-ROM.
RAM Slots
CPU Slot
66
67
6. Microprocessor/Processor
●Processor accepts inputs from user as a format of data/information and
processes using instructions, finally produces output to the user.
• The two most common types of programs are system software and
application software.
75
System Software
• System software exists primarily for the computer itself, to help the
computer perform specific functions.
• One major type of system software is the operating system (OS). All
computers require an operating system.
• The OS tells the computer how to interact with the user and its own
devices.
Today, many computers use an operating system that has a graphical user interface (GUI) that
provides visual clues such as icon symbols to help the user.
• DOS (Disk Operating System) is an older but still widely used operating system that is text-
based.
Continued….
Other System Softwares- Programs that manage the computer- eg. Compiler,interpeter
Compiler- Compiler converts the entire high level language to machine languag and stored in
memory and executed when needed.
Interpreter- Converts high level language one line at a time to machine language and then executes it
3. Definiteness: Each instruction must be clear and well defined-there should be no ambiguity
4. Finiteness: Algorithms must terminate after performing required task/specified time- should not
enter into an infinite loop
7. Effectiveness: All the operations to be performed in the algorithm must be sufficiently basic
that they can in principle be done exactly and in a finite length of time.
Flow Chart
Oval Start/Stop
Rectangle Processing
Continued….
Arrows Connections
Hexagon Looping
Flow Chart
Start
Read a and b
sum=a+b
Print sum
Stop
1. Write a algorithm to find out number is odd or
even. Draw its flowchart.