0% found this document useful (0 votes)
70 views21 pages

ME 2002 Computer Programming-I: Course Teachers

This document provides information about a computer programming course taught at Dhaka University of Engineering & Technology. It lists the course teachers, Dr. Md. Anowar Hossain and Biplob Kumar Roy, and provides basic information about computer components, data representation, and programming languages.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
70 views21 pages

ME 2002 Computer Programming-I: Course Teachers

This document provides information about a computer programming course taught at Dhaka University of Engineering & Technology. It lists the course teachers, Dr. Md. Anowar Hossain and Biplob Kumar Roy, and provides basic information about computer components, data representation, and programming languages.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 21

ME 2002

Computer Programming-I
Course Teachers:
Dr. Md. Anowar Hossain
Associate Professor, Department of Mechanical Engineering
Biplob Kumar Roy
Lecturer , Department of Mechanical Engineering

Dhaka University of Engineering & Technology


Gazipur, Bangladesh 1
Computer???
 Special type of machine
 Stores huge amount of information
 Perform mathematical calculation
 Perform task at speeds much faster human beings
 can think.
 Do not think like human being
 Only can follow the steps contained in their program

2
Typical Computer Block Diagram
Main Secondary
memory memory

Internal
Memory
(registers)

Input Output
devices Control devices
Unit

Arithmetic
logic
Unit

Central
Central processing
processing unit
3
Major Components of a Computer
• The CPU: The central processing unit is the heart of any computer. It is
divided into a control unit, an arithmetic logic unit (ALU), and internal
memory.

• Control Unit: Controls all other parts of the computer, interprets the
instruction of the program, fetches data from input devices or main
memory, send data to output devices or main memory etc.

• ALU: Performs the actual mathematical calculations.

• Internal Memory: Consists of series of memory registers used for the


temporary storage of intermediate results during calculations.

4
Major Components of a Computer (Contd..)

• Main Memory: Semiconductor chips, fast (can be


fetched data for use in 100 nanoseconds or less
on a modern computer) & expensive, used to
temporarily store the program, volatile.
• Secondary Memory: Disks or magnetic tape,
slower & less expensive, store much information
permanently, nonvolatile. Ex. Hard disks, CD,
DVD, Blue ray disk, Floppy disk, etc.

5
Major Components of a Computer (Contd..)
• Input and output device: Data is entered into a
computer through an input device and is output
through an output device.

• Input device: Key board, mouse, scanner,


microphone, etc.

• Output device: Monitor, printers, plotters,


speakers, etc.

6
Data Presentation in a Computer

 Computer memories are composed of millions of


individual switches, each of which can be ON or OFF
switches.

 Each switch represents one binary digit(called bit).

 ON state is interpreted as binary 1 and OFF state is


interpreted as binary 0

 When several bits are grouped together, they can be used


to represent numbers in the binary (base 2) number
system.

7
Data Presentation in a Computer (Contd..)
• The smallest common grouping of bits is called a byte.
Byte is a group of 8 bits used to represent a binary
number. It is the fundamental unit to measure the
capacity of a computer’s memory.

• The next larger grouping of bits in an computer is called


a word. Word is a group of 2,4, or more consecutive
bytes used to represent a single number in memory. The
size of a word varies from computer to computer so it is
not used to measure the capacity of a computer
memories.

8
Decimal and Binary Number System
Decimal number system ( Base 10)
122
1’s place (100)
10’s place (101)
100’s place (102)

The number 12210 is really (1×102) + (2 ×101) + (2 ×100).


Binary number system ( Base 2)
101
1’s place (20)
2’s place (21)
4’s place (22)

The number 1012 is really (1×22) + (2 ×21) + (2 ×20) = 5


9
10
The Binary Number System (Contd..)
 Three binary digits (bits) can represent 8 possible
values: 0 (= 0002) to 7 (= 1112). n bits can represent 2n
possible values.
 1 byte can represent 256 possible values.
 2 bytes can represent 65,536 possible values.
 Half of the values are for representing negative
numbers and half for positive.
 1 byte is usually used to represent numbers between
-128 and +127

11
Types of data stored in Memory
3 types of data are stored in a computer’s memory: Character
data, Integer data & Real data.
Character data:
 The 26 uppercase letters A through Z

 The 26 lowercase letters a through z


 The 10 digits 0 through 9
 Miscellaneous common symbols, such as “ , () ! % $ ^ # @ & *
etc.
 Any special letters or symbols required by the language, such as
à, ç, ë, £, etc.

12
Types of data stored in Memory (Contd..)
 1 byte of memory is used to store each character
 Two coding systems ASCII & EBCDIC are used to represent
character or symbol
 ASCII- American Standard Code for Information Interchange.
Most of computer manufacturers in the world used the ASCII
coding system.
 EBCDIC- Extended Binary Coded Decimal Interchange Code.
IBM uses EBCDIC on its mainframe computers.
 Chinese and Japanese contain around 4000 characters so they use
a new coding system called Unicode in which each character is
stored in 2 bytes of memory. The UNICODE coding system can
represent character data in any language.
13
Types of data stored in Memory (Contd..)

Integer Data

 Examples: 1,2, 400, -2, 311, -500 etc.

 Integer data type consists - positive integer, negative


integer, and zero.

 Memory devoted to storing an integer varies from


computer to computer such as 1, 2, 4 , or 8 bytes. 4
bytes are common type.

14
Types of data stored in Memory (Contd..)

• The smallest number that can be stored in an n bit integer is,


Smallest integer value = - 2n-1

• The largest integer value = 2n-1 - 1.

• For 4-byte integer, the range will be -2,147,483,648 to


2,147,483,647.

• Attempts to use an integer larger than largest possible value or


smaller than smallest possible value cause an overflow condition

15
Types of data stored in Memory (Contd..)

The integer data type has two fundamental limitations:

• It is not possible to represent numbers with fractional


parts (0.25, 1.5, 3.14159, -2.3 etc.) as integer data.

• It is not possible to represent very large positive integers


or very small negative integers because not enough bits
are available to represent the value.

To get around these limitations, computers include a real or


floating point data type.

16
Types of data stored in Memory (Contd..)
Real Data
 Stores numbers in a type of scientific notations.
 Ex. 299,800,000 m/s is converted to 2.998  108 m/s.
 2.998 part is called mantissa and the exponent (in the 10 system)
is 8.
 Real numbers usually occupy 32 bits of memory: a 24 -bits
mantissa and an 8-bits exponent.
 Computer works in the base 2 system instead of the base 10
system for real data handling
Value = mantissa  2exponent.

17
Computer Languages
Computer Program???
• A program is the tool a user employs to exploit the power of the computer.
• A program is written in a language which is understood by the computer
hardware.
• A program consists of a sequence of steps which when executed result in a
task being carried out. Execution means that the computer is able to
interpret each step (instruction), interpretation refers to understanding what
is required and instructing the hardware to carry it out. Each instruction
might require a calculation to be performed, or a decision to be selected, or
some information to be stored or retrieved. The nature of the instruction
depends on what programming language is used.
• Each programming language has its own set of statements.

18
Computer Languages

Available Programming Languages:

• Operation codes (machine language) use strings of 0s and 1s to


express instructions and they dependent on the underlying
hardware.
• Assembly languages are also dependent on hardware and utilize a
symbolic form to express instructions.
• High level languages were developed to ease the programming
effort and to provide hardware independence. For example, Fortran
is popular with the scientific and engineering community, Cobol is
used for business applications and C for systems programming.

19
History of the FORTRAN
 Fortran is the grandfather of all scientific languages.
 The name Fortran is derived from FORmula TRANSlation
 Fortran was first developed in 1954 by IBM.

 In 1958 and 1962 Fortran II and IV, respetively, was released.


 In 1966 Fortran IV was adopted as an ANSI standard, and it came
to be known as Fortran 66.
 In 1977 the update version of Fortran was released as Fortran 77
 Next update was Fortran 90
 In 1997 the minor update of Fortran 90 was Fortran 95

20
PROGRAM QES
IMPLICIT NONE
INTEGER :: a, b, c, D
REAL :: Real_Part, Imag_Part
WRITE(*,*) ''Type in values for a, b and c''
READ(*,*) a, b, c
IF (a /= 0) THEN ! Calculate discriminant
D = b*b-4*a*c
IF (D == 0) THEN ! one root
WRITE(*,*) ''Root is '', ­b/(2.0*a)
ELSE IF (D > 0) THEN ! real roots
WRITE(*,*) ''Roots are'',(­b+SQRT(REAL(D)))/(2.0*a),&
''and'', (­b­SQRT(REAL(D)))/(2.0*a)
ELSE ! complex roots
Real_Part = ­b/(2.0*a) ! D < 0 so must take SQRT of ­D
Imag_Part = (SQRT(REAL(­D))/(2.0*a))
WRITE(*,*) ''1st Root'', Real_Part, ''+'', Imag_Part, ''i''
WRITE(*,*) ''2nd Root'', Real_Part, ''­'', Imag_Part, ''i''
END IF
ELSE !a=0
WRITE(*,*) ''Not a quadratic equation''
END IF
END PROGRAM QES

You might also like