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

Week 2

This document provides a summary of lectures 3 and 4 of a programming languages course. It discusses the course website, an introduction to programming languages including what a computer is and computer organization. It also covers the evolution of operating systems, personal and distributed computing, and the boot process. Finally, it discusses machine languages, assembly languages, high-level languages, debugging high-level languages including types of errors, and the trend toward object-oriented programming.

Uploaded by

M Noaman Akbar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
47 views

Week 2

This document provides a summary of lectures 3 and 4 of a programming languages course. It discusses the course website, an introduction to programming languages including what a computer is and computer organization. It also covers the evolution of operating systems, personal and distributed computing, and the boot process. Finally, it discusses machine languages, assembly languages, high-level languages, debugging high-level languages including types of errors, and the trend toward object-oriented programming.

Uploaded by

M Noaman Akbar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 22

Programming Languages

for Mathematics
Week 2
Lecture 3 and 4
Shakeel Ahmad
Minhaj University, Lahore

Course Web Site


Course web site is available at:
www.sites.google.com/site/mulshakeel
Web site contains the following information:

Administrative information
Course Syllabus
Homework assignments
Class notes
Class programs
Compiler instructions
Link to the class mailing list
5

Introduction to
Programming Languages
The purpose of this course is to teach
you about computing, but particularly,
programming in C++ (a powerful,
widely-used programming language).

What Is a Computer?
Computer
Performs computations and makes logical decisions
Millions / billions times faster than human beings

Computer programs
Sets of instructions by which a computer processes
data

Hardware
Physical devices of computer system

Software
Programs that run on computers

Computer Organization
Six logical units of computer system
Input unit
Mouse, keyboard

Output unit
Printer, monitor, audio speakers

Memory unit
Retains input and processed information

Arithmetic and logic unit (ALU)


Performs calculations

Central processing unit (CPU)


Supervises operation of other devices

Secondary storage unit


Hard drives, floppy drives

Evolution of Operating
Systems
Batch processing
One job (task) at a time
Operating systems developed
Programs to make computers more convenient to
use
Switch jobs easier

Multiprogramming
Simultaneous jobs
Timesharing operating systems

Personal Computing, Distributed


Computing, and Client/Server
Computing
Personal computers
Economical enough for individual
Popularized by Steve Jobs and Steve
Wozniak with the introduction of the Apple
in 1977.
In 1981 IBM introduced the IBM personal
computer using off the shelf components.

10
2003 Prentice Hall, Inc. All rights reserved.

(modified by Evan Korth)

The boot process


The process by which a machine comes up from
rest state to the state that is usable is known as
booting
When the power is turned on
The CPU runs the BIOS (Basic Input / Output
System)
Usually located on a chip on the motherboard
Runs POST (Power On Self Test) of various hardware
components
Loads the boot sector program

11

The boot process (continued)


Boot Sector Program
Located in the first sector of the hard disk or other
disk
Is responsible for loading the rest of the operation
system into the RAM

Operating System
Once it is loaded, it configures the various
hardware components
Then it waits for the user to issue commands
Then you can run your applications

12

Machine Languages, Assembly


Languages, and High-level Languages

Three types of programming languages


Machine languages
Strings of numbers giving machine specific instructions
Example:
+1300042774 (these would really be in binary)
+1400593419
+1200274027

Assembly languages
English-like abbreviations representing elementary
computer operations (translated via assemblers)
Example:
LOAD
ADD
STORE

BASEPAY
OVERPAY
GROSSPAY
13

Machine Languages, Assembly


Languages, and High-level Languages
High-level languages
Instructions closer to everyday English
English is a natural language. Although high level
programming languages are closer to natural languages, it is
difficult to get too close due to the ambiguities in natural
languages (a statement in English can mean different things
to different people obviously that is unacceptable for
computer programming). However, this is a big research area
of computer science.

Use mathematical notations (translated via compilers)


Example:
grossPay = basePay + overTimePay

Interpreter Executes high level language programs


without compilation.

14

Some Procedural High-level


Languages
Other high-level languages
FORTRAN
Used for scientific and engineering applications

COBOL
Used to manipulate large amounts of data

Pascal
Intended for academic use

15

The Key Software Trend: Object


Technology
Objects
Reusable software components that model items in
the real world
Meaningful software units
Date objects, time objects, paycheck objects, invoice objects,
audio objects, video objects, file objects, record objects, etc.
Any noun can be represented as an object

Very reusable
More understandable, better organized, and easier to
maintain than procedural programming
Favor modularity

16

Debugging with High Level


Languages
The process of finding and removing
programming errors is called debugging.
There are types of errors or bugs are
occurred while writing a program in high
level languages like C, C++.

Types of Errors
Syntactic Errors
Input code is not legal
Caught by compiler (or other translation mechanism)

Semantic Errors
Legal code, but not what programmer intended
Not caught by compiler, because syntax is correct

Logical / Algorithmic Errors


Problem with the logic of the program
Program does what programmer intended,
but it doesn't solve the right problem

Syntactic Errors
Common errors:
missing semicolon or brace
mis-spelled type in declaration

One mistake can cause an avalanche of errors


because compiler can't recover and gets confused
missing semicolon
main () {
int i
int j;
for (i = 0; i <= 10; i++) {
j = i * 7;
printf("%d x 7 = %d\n", i, j);
}
}

Semantic Errors
Common Errors
Missing braces to group statements together
Confusing assignment with equality
Wrong assumptions about operator precedence, associativity
Wrong limits on for-loop counter
Uninitialized variables h
missing braces,
so printf not part of if
main () {
int i
int j;
for (i = 0; i <= 10; i++)
j = i * 7;
printf("%d x 7 = %d\n", i, j);
}

Algorithmic Errors
Design is wrong,
so program does not solve the correct problem
Difficult to find
Program does what we intended
Problem might not show up until many runs of program

Maybe difficult to fix


Have to redesign, may have large impact on program code

Classic example: Y2K bug


only allow 2 digits for year, assuming 19__

You might also like