0% found this document useful (0 votes)
0 views

Lecture 6 - Intro to Prog

The document provides an overview of Information and Communication Technology (ICT) applications, focusing on computer systems, hardware, software, and programming languages. It discusses the components of computer systems, including the CPU, memory types, and I/O devices, as well as the different categories of computers and software. Additionally, it covers programming concepts, errors, and the development cycle in programming.

Uploaded by

ali71803j
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
0 views

Lecture 6 - Intro to Prog

The document provides an overview of Information and Communication Technology (ICT) applications, focusing on computer systems, hardware, software, and programming languages. It discusses the components of computer systems, including the CPU, memory types, and I/O devices, as well as the different categories of computers and software. Additionally, it covers programming concepts, errors, and the development cycle in programming.

Uploaded by

ali71803j
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 52

Applications of

ICT
By Dr. Mir Yasir Umair
Associate Professor, MCS, NUST

Computer
Computers
Systems
o Devices for performing computations at high speeds with great accuracy
o A machine that can be programmed to manipulate symbols. Can perform complex & repetitive
procedures quickly, precisely and reliably. Can quickly store and retrieve large amounts of data.

• Program
o A set of instructions for a computer to follow, written in specific programming language
Computers and Computer Languages
• Computers are everywhere
o how many computers do you own?

• Computers are useful because they run programs


o program is simply a set of instructions to complete some task
o how many different programs do you use in a day?
Definitions
• program: A set of instructions that are to be carried out
by a computer.

• program execution: The act of carrying out the


instructions contained in a program.
o this is done by feeding the instructions to the CPU

• programming language: A systematic set of rules used


to describe computations, generally in a format that is
readable and editable by humans.
o in this class we use Java
Computer Systems
• Hardware (HW)
oActual physical machines (equipment) that
make up the computer
• Software (SW)
oA collection of programs used by a computer
oA set of instructions provided by the
programmer that the computer follows.
oProgram instructions have to be stored in main
memory before they can be executed.
Computer Systems
• Computer Categories:
o Microcomputers (Personal computers / PCs)
• Used by a single person
o Workstations:
• Largest microcomputers
o Minicomputers:
• Can be used by many people simultaneously by using several terminals
connected to the same CPU
o Main frame computers:
• Faster & larger than minicomputers
o Super computers:
• Most powerful mainframe computers
• Of which category is you computer at home??
Hardware (HW): Organization
• Computer HW usually consists of:
o CPU
o Main memory (RAM & ROM)
o I/O Devices
o Secondary Memory
• CPU & main memory are the heart of the computer
• Usually the CPU, main memory and secondary memory are housed in a
single cabinet

I/O Devices
CPU

Secondary Memory

Main Memory
Hardware (HW):
Central Processing Unit (CPU)
• Executes programs
• Performs calculations
o Arithmetic
• Add, subtract, divide, multiply, … etc.
o Logical
• Compare, test for true/false
• Controls & coordinates the other parts of the computer.
• The CPU controls just about everything else by executing
instructions
o stores data in memory
o retrieves data from memory
o performs computations
o sends and gets data from other devices
Hardware (HW): Memory
• Main (Primary) Memory:
o Ordered sequence and specific number of memory locations
(Bytes, words) that have unique addresses indicating their
relative positions
o Fast, expensive, short term memory
o Holds intermediate results and serves as “scratch paper”
o Needed to carry out program instructions
o Types:
• RAM: Random Access Memory
(vs. Sequential Access Memory)
• Volatile (i.e. contents disappear when the computer is switched off)
• Writable (except where forbidden by the software)
• ROM: Read Only Memory
• Non-volatile
• Also usually random access
Hardware (HW): Memory
• Secondary (auxiliary) memory
o Used for keeping a permanent records of information
o Holds programs and data between jobs
o Keeps data or program files for later use
o Slower, cheaper, long-term memory
o Common forms
• Diskettes, magnetic tapes, hard disk, CD-ROM’s, DVD
o Some types are removable
Hardware (HW)
• I/O (Input/Output) devices
o Allow the user to communicate with the computer.
o A single computer could be connected to more than one input or output device.
o Examples:
• Input: Keyboard, mouse, scanner, voice
• Output: Screen, printer, voice
Hardware Devices
( Examples)
• Input:
o Keyboard
o Mouse, Touchpad, Joystick
o Pen & tablet, Perforated cards
• Output:
o Printer
o Screen (monitor)
o Teletype
• Input & Output:
o Auxiliary Devices:
• disks (hard disk, floppies, DVDs/CDs, USB keys, Flash memories)
• tape drives
o Touch screen
o Network cards (intranet, internet)
Hardware Devices (3)
• Bus: A group of wires through which the other devices
communicate.

I/O devices are controlled by drivers, which are very specialized


kinds of programs
Hardware Trends
• Every year or two computer power approximately doubles
o Memory size (RAM)
• Memory used to execute programs
o Secondary storage (permanent storage)
• E.g. disk storage, used to to hold programs and data over time
o Processor speeds
• Speed at which computers execute their programs
Hardware/Software Trends
• Applications:
o Rapidly increasing hardware power allows applications to get bigger and more complex

• Costs
o Hardware costs dropping
o Software development costs rising
• Software development complexity
• Programmer salaries
• Cost of slipping schedules
o Unanticipated interactions in complex systems
o Unpredictability of software development times
Hardware/Software
Architectures
• Mainframe Era
o 1940’s-70’s: mainframe computer, minicomputers
o Environments:
• Batch environments, batch processing
o Files are basis for I/O: fixed formats, minimal device I/O
o Error recovery
o Lack of timing constraints
• Interactive environments
o Terminal and file I/O:
o Interactive error handling
o Faster performance
• Personal Computers Era
o 1978: the Apple II ran BASIC
• Educational use
o 1981: IBM released the first PC
o 1984: Macintosh
o Window environments:
• OO models are ideal (Smalltalk)
• Must interact with many I/O devices (file I/O is less important)
o Embedded systems
• Error handling
• Real-time response
• Distributed systems with concurrently running tasks
• Networking Era:
o LANs (Local Area Networks):
client-server model
• Airline reservations, banking
o Internet
• 70’s: ARPANET: telnet, FTP, SMTP protocols
• late 80’s: HTML and HTTP added
o Issues and Effects:
• Static web pages with URLs for access
URL = Uniform Resource Locator
• Dynamic web pages for e-commerce (Perl, JAVA, etc.)
• Security
• Performance (multiple clients)
o Offloading work to client
Hardware/Software Concepts
• Computers manipulate instructions and data
o Represented in similar ways
o Used in different ways
o Representation is binary (digital hardware is binary)
• Numbers vs. symbols
o Computers represent everything as numbers
o But numbers can represent symbols
o Can perform “symbolic” computation
• Beginning of Artificial Intelligence
HW/SW Concepts: Data
· What is it?
- Numbers, characters, images, or other method of recording
- Can be assessed by a human or (especially) input into a computer, stored and
processed there, or transmitted on some digital channel.
- Nearly always represent data in binary.
- Has no meaning on its own.
- When interpreted by data processing system it takes on meaning and becomes
information.
· Storage
o Setting of individual bits to specific values, destroying its previous contents
· Retrieval
o Copying the contents of a particular memory cell to another storage area.
o Original data remains unchanged
HW/SW Concepts: Representation
• Digit / Bit
o Smallest unit of information/storage, sufficient to hold one bit
o Can take one of two values
(true/false, 1/0, or yes/no)
o Corresponds to an input/output being on or off
• Byte
o Smallest addressable unit of storage
o Usually 8 bits
o Typically holds one character
o Can represent 256 different values
HW/SW Concepts: Representation
• Word
o Fundamental unit of storage in a computer
o Word size is one of its chief distinguishing characteristics of a computer
o Typical size in modern computers: 32 bits (4 bytes) or 64 bits (8 bytes)
o An instruction is usually one or more words long
o A word can be used to hold a whole number of characters
Software
Categories
Software Categories
• System SW
o Programs written for computer systems
• Compilers, operating systems, …
• Application SW
o Programs written for computer users
• Word-processors, spreadsheets, & other application
packages
A Layered View of the Computer
Application Programs
Word-Processors, Spreadsheets,
Database Software, IDEs,
etc…
System Software
Compilers, Interpreters,Preprocessors, etc.
Operating System, Device Drivers

Machine with all its hardware


Operating System (OS)
· Provides several essential services:
o Loading & running application programs
o Allocating memory & processor time
o Providing input & output facilities
o Managing files of information
Programs
• Programs are written in programming languages
o PL = programming language
o Pieces of the same program can be written in different PLs
• Languages closer to the machine can be more efficient
• As long as they agree on how to communicate
• A PL is
o A special purpose and limited language
o A set of rules and symbols used to construct a computer
program
o A language used to interact with the computer
Computer Languages
– Machine Language
• Uses binary code
• Machine-dependent
• Not portable
• Assembly Language
o Uses mnemonics
o Machine-dependent
o Not usually portable
• High-Level Language (HLL)
o Uses English-like language
o Machine independent
o Portable (but must be compiled for different platforms)
o Examples: Pascal, C, C++, Java, Fortran, . . .
Machine Language
• The representation of a computer program which is actually read
and understood by the computer.
o A program in machine code consists of a sequence of machine instructions.
• Instructions:
o Machine instructions are in binary code
o Instructions specify operations and memory cells involved in the operation
Example:

Operation Address

0010 0000 0000 0100

0100 0000 0000 0101

0011 0000 0000 0110


Assembly Language
• A symbolic representation of the machine language of a specific
processor.
• Is converted to machine code by an assembler.
• Usually, each line of assembly code produces one machine
instruction (One-to-one correspondence).
• Programming in assembly language is slow and error-prone but is
more efficient in terms of hardware performance.
• Mnemonic representation of the instructions and data
• Example:
Load Price
Add Tax
Store Cost
High-level language
• A programming language which use statements consisting of
English-like keywords such as "FOR", "PRINT" or “IF“, ... etc.
• Each statement corresponds to several machine language
instructions (one-to-many correspondence).
• Much easier to program than in assembly language.
• Data are referenced using descriptive names
• Operations can be described using familiar symbols
• Example:
Cost := Price + Tax
Syntax & Semantics
• Syntax:
o The structure of strings in some language. A language's syntax is
described by a grammar.
o Examples:
• Binary number
<binary_number> = <bit> | <bit> <binary_number>
<bit> =0|1
• Identifier
<identifier> = <letter> {<letter> | <digit> }
<letter> =a|b|...|z
<digit =0|1|...|9
• Semantics:
o The meaning of the language
Syntax & Grammars
• Syntax descriptions for a PL are themselves written in a formal
language.
o E.g. Backus-Naur Form (BNF)

• The formal language is not a PL but it can be implemented by a


compiler to enforce grammar restrictions.
• Some PLs look more like grammar descriptions than like
instructions.
Compilers & Programs
• Compiler
o A program that converts another program from some source language (or high-level programming
language / HLL) to machine language (object code).
o Some compilers output assembly language which is then converted to machine language by a
separate assembler.
o Is distinguished from an assembler by the fact that each input statement, in general, correspond to
more than one machine instruction.
Compilation into Assembly L
Source Assembly
Program Compiler Language

Assembly Assembler Machine


Language Language
What is a Linker?
• A program that pulls other programs together so that they
can run.
• Most programs are very large and consist of several
modules.
• Even small programs use existing code provided by the
programming environment called libraries.
• The linker pulls everything together, makes sure that
references to other parts of the program (code) are
resolved.
An Important Realization
• Computers are stupid.

• Computers can’t read minds.

• Computers seldom make mistakes.

• If the computer is not doing what we want, it’s because WE made a


mistake.
• Users are not always very intelligent
A Simple C++ Program
• Preprocess directives are not
statements (no semi-colon ;)

• Extra space in < >

• Case Sensitive
o Main vs main
Listing 1.2

• Output?
Listing 1.3

• Output?
Output?
C++ Program

Development Cycle
Programming Style and
Documentation
• Appropriate Comments
• Comment Styles
• Proper Indentation and Spacing
Errors?
Programming Errors
• Syntax Errors

• Runtime Errors

• Logic Errors
Programming Errors
• Syntax Errors
;
Programming Errors
• Syntax Errors

• Runtime Errors
Programming Errors
• Syntax Errors

• Runtime Errors

• Logic Errors
Common Errors

Missing Braces, Semicolons, Quotation Marks and Misspelling Names


Work…
. Homework
• Think of 3 tasks you have encountered in your studies
that you would like to write a program for.
• Deadline.. Next class
Thanks
Questions ???

You might also like