welcome to the course of computer programming be i year · 2011. 7. 11. · 5/1/2006 computer...
TRANSCRIPT
Welcome to the course of
Computer ProgrammingBE I Year
L T P
Credit 3 0 2Marks 76 0 24
Computer Science & Engineering Department
Thapar Institute of Engineering & Technology, Patiala-147004
Instructor : Mr. Deepak Garg
Introduction
Minor1 + Minor2 + Quiz1 + Quiz2 + Final
12 + 12 + 8 + 8 + 36= 76
16 Labs + Viva
16 + 8 = 24
5/1/2006 Computer Programming TA 103 BE I year 3
Fundamentals
What is a computer?
5/1/2006 Computer Programming TA 103 BE I year 4
Introduction
Computer is an electronic device used to process data
Block Diagram:-
Processor+
MemoryInput Device
Output Device
5/1/2006 Computer Programming TA 103 BE I year 5
Need of the subjectNow integrated into all walks of life1. Homes2. Schools3. Colleges & Universities4. Banks5. Hospitals6. Industry7. Biotechnology8. Research & development9. Defense10. Agriculture11. Publishing12. Entertainment
5/1/2006 Computer Programming TA 103 BE I year 6
Relevant to all branches like
-Civil
-mechanical
-electrical
-electronics
-chemical
-instrumentation and
-Biotechnology
Difficult to survive without the knowledge of basic computing
5/1/2006 Computer Programming TA 103 BE I year 7
SyllabusINTRODUCTION : Elements of Computer processing; Hardware and Software; Problem solving- Algorithms and Flowcharts.programming basics: basic program construction; console I/O(printf, scanf), preprocessor directives, comments , data types ,type conversions , operators - arithmetic , relational , logical , conditional , increment/decrement; library functions ;header filesLOOPS AND DECISIONS : for loop , while loop , do loop ; various forms of if statement ; switch statement ; break statement , continue statement , go to statement.ARRAYS AND STRINGS: Declaring an array, Initializing arrays, accessing the array elements, working with multidimensional arrays, declaring and initializing string variables, arithmetic operations on characters, string handling functions.
5/1/2006 Computer Programming TA 103 BE I year 8
Syllabus
Pointers: declaring and initializing pointers, pointer expressions, pointer increment and scale factor, pointers and arrays , pointers and strings
FUNCTIONS : simple functions , passing arguments to functions , returning values from functions , reference arguments , pointers and functions
STRUCTURES: Declaring and initializing a structure, accessing structure members , structure within structure, Array of structures, structures and functions .
5/1/2006 Computer Programming TA 103 BE I year 9
Syllabus
FILES & STREAMS: reading and writing to text and binary files, character I/O , string I/O , file pointers , error handling , redirection , command line arguments
OBJECT oriented programming: exposure of object oriented concepts and its advantages over structured programming
Introduction to C++ in brief covering its enhancements over C
5/1/2006 Computer Programming TA 103 BE I year 10
Four parts
Computer Consists of four parts1. Hardware : The Parts you can see and
touch2. Software: Also called programs consists of
organized sets of instructions for controlling the computer
3. Data : consists of raw facts which the computer can manipulate and process into useful information
4. Users: people are users as operators or programmers
5/1/2006 Computer Programming TA 103 BE I year 11
Hardware
1. Processor
2. Memory
3. I/O Devices
4. Storage devices
5/1/2006 Computer Programming TA 103 BE I year 12
Processor
Also called Central Processing Unit. It manages all devices and performs the actual processing of data
It consists of one or more chips attached to the computer’s main circuit board
(mother board)
5/1/2006 Computer Programming TA 103 BE I year 13
Memory
Smallest unit of memory is byte. It contains 8 bits.
Kilobyte 1024 bytes
Megabyte 1024 KB
Gigabyte 1024 MB
Terabyte 1024 GB
5/1/2006 Computer Programming TA 103 BE I year 14
Memory
Cache Memory (Volatile, inside the Processor, costly, very fast) Primary memory-
RAM-Random Access Memory
(volatile, fast, costly, on the motherboard)
ROM-Read Only memory
(Non-volatile, written by the manufacturer, on the motherboard)
Cache Memory (Volatile, on the board, very fast, various levels)
5/1/2006 Computer Programming TA 103 BE I year 15
Memory
Secondary Memory (Non-volatile, slow, cheap)
e.g. Hard disk
External memory ( CD, Floppy, DVD etc.)
5/1/2006 Computer Programming TA 103 BE I year 16
Cache Memory
Hard Disk RAM
5/1/2006 Computer Programming TA 103 BE I year 17
Floppy CD drive interior Pen or thumb drive
5/1/2006 Computer Programming TA 103 BE I year 18
Abacus (750 BC) Napier’s Bones (1600 AD)
5/1/2006 Computer Programming TA 103 BE I year 19
Pascal’s Adding Machine
Marie Jacquard’s Loom
with Punched Cards (1810 AD)
5/1/2006 Computer Programming TA 103 BE I year 20
Babbage’s Difference Engine
1822 ADBabbage’s Analytical
Engine (1833 AD)
5/1/2006 Computer Programming TA 103 BE I year 21
Hollerith’s Card
Reader (1877AD) Mark-I (1937
5/1/2006 Computer Programming TA 103 BE I year 22
ENIAC : (1946 AD ) EDVAC : (1949 AD )
5/1/2006 Computer Programming TA 103 BE I year 23
UNIVAC (1951 AD ) IBM 650 (1955)
5/1/2006 Computer Programming TA 103 BE I year 24
PDP – 8 1964 CDC 3600(1965)
5/1/2006 Computer Programming TA 103 BE I year 25
IBM 370 (1970) PCs(1977)
5/1/2006 Computer Programming TA 103 BE I year 26
CRAY SV1 (supercomputer) Workstation
5/1/2006 Computer Programming TA 103 BE I year 27
Laptops Handheld computers
5/1/2006 Computer Programming TA 103 BE I year 28
Input Devices
Accept data and instructions from the user or from another computer system
5/1/2006 Computer Programming TA 103 BE I year 29
KeyBoard Mouse
5/1/2006 Computer Programming TA 103 BE I year 30
Scanner Joy Stick
5/1/2006 Computer Programming TA 103 BE I year 31
Light Pen Web Camera
5/1/2006 Computer Programming TA 103 BE I year 32
Touch Screen Mike
5/1/2006 Computer Programming TA 103 BE I year 33
Output Devices
Return Processed data back to the user or other computer system
5/1/2006 Computer Programming TA 103 BE I year 34
Laser Printer Ink Jet Printer
5/1/2006 Computer Programming TA 103 BE I year 35
Dot Matrix Printer Line Printer
5/1/2006 Computer Programming TA 103 BE I year 36
Speakers Monitor
5/1/2006 Computer Programming TA 103 BE I year 37
Software
System Software- To help the computer to perform specific functions for itself. One major example is operating system. All computers require an operating system. E.g. DOS ( Disk operating System, Windows 98, Windows 2000, Windows XP, Windows NT, Linux, UNIX etc.
5/1/2006 Computer Programming TA 103 BE I year 38
OS as a resource manager
Memory Management
Device Management
Storage Management
GUI ( Graphical User Interface)
5/1/2006 Computer Programming TA 103 BE I year 39
Application Software:
Tells the computer how to accomplish tasks the user requires
Word processing Programs
Database management
Presentation Programs
Graphics Programs
Entertainment and education
Networking software
Internet applications
Business application etc.
5/1/2006 Computer Programming TA 103 BE I year 40
Programming Languages
Machine Language
Assembly Language
Procedural Languages BASIC, COBOL, FORTRAN, Pascal
Structured Language C
Object oriented languages C++, Java etc.
Visual Programming VC++, VB etc.
5/1/2006 Computer Programming TA 103 BE I year 41
Compiler
Compiler : Converts a program from High Level Language to Low level Language
5/1/2006 Computer Programming TA 103 BE I year 42
Networking
A network is a collection of a number of computers to allows sharing of information and resourses in a computer system
LAN
MAN
WAN
5/1/2006 Computer Programming TA 103 BE I year 43
Modem Router NIC Card
5/1/2006 Computer Programming TA 103 BE I year 44
Internet
Largest network on earth
Machine and language independent
Searching
Communication
Online shopping
Cultural changes
Repository of data
5/1/2006 Computer Programming TA 103 BE I year 45
History of C
Evolved from two other programming languages BCPL and B in 1971 and 1972
“Dennis Ritchie (Programmer at Bell Laboratories)
Added data typing, other features 1978 first version of C came
Development language of UNIX Hardware independent
Portable programs
1989: ANSI standard 1990: ANSI and ISO standard published
ANSI/ISO 9899: 1990
5/1/2006 Computer Programming TA 103 BE I year 46
History of C++
Extension of C
Early 1980s: Bjarne Stroustrup (Bell Laboratories)
“Spruces up” C
Provides capabilities for object-oriented programming
Hybrid language
C-like style
Object-oriented style
Both
5/1/2006 Computer Programming TA 103 BE I year 47
number systemDecimal Binary Octal Hexadecimal
0 0000 0 01 0001 1 12 0010 2 23 0011 3 34 0100 4 45 0101 5 56 0110 6 67 0111 7 78 1000 10 89 1001 11 910 1010 12 A11 1011 13 B12 1100 14 C13 1101 15 D14 1110 16 E15 1111 17 F
5/1/2006 Computer Programming TA 103 BE I year 48
Conversion to decimal
binary number 101101 20 * 1 + 21 * 0 + 22 * 1 + 23 * 1 + 24 * 0 + 25*1 = 1+0+4+8+0+32 = 45
Octal number 652
80 * 2 + 81 * 5 + 82 * 6 = 2+40+384 = 426
Hexadecimal Number 1AF73 160 * 3 + 161 * 7 + 162 * F + 163 * A + 164 * 1 = 160 * 3 + 161 * 7 + 162 * 15 + 163 * 10 + 164 * 1
= 3 + 112 + 3840 + 40960 + 65536 =110451
5/1/2006 Computer Programming TA 103 BE I year 49
Algorithm
An Algorithm is a finite sequence of
steps where each step is unambiguous
and which terminates for all possible
inputs in a finite amount of time.
5/1/2006 Computer Programming TA 103 BE I year 50
Flow Chart
Visual Representation of the steps to solve a problem.
5/1/2006 Computer Programming TA 103 BE I year 51
Problem Solving
use a systematic approach to arrive at the solution of a problem
Understand the problem statement
First think about the known and unknown variables in the problem
Think of the logical steps to solve the problem
What is the input and output of problem
5/1/2006 Computer Programming TA 103 BE I year 52
Algorithm-computing the Sum
Compute Sum:
1. Initialize sum to 0
2. Input new number
3. If new number is 0 go to step 6
4. Add the next number to the sum
5. Go to step 2
6. Report the sum
5/1/2006 Computer Programming TA 103 BE I year 53
Questions are welcome !