welcome to the course of computer programming be i year · 2011. 7. 11. · 5/1/2006 computer...

53
Welcome to the course of Computer Programming BE I Year L T P Credit 3 0 2 Marks 76 0 24 Computer Science & Engineering Department Thapar Institute of Engineering & Technology, Patiala-147004 Instructor : Mr. Deepak Garg

Upload: others

Post on 18-Aug-2020

0 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Welcome to the course of Computer Programming BE I Year · 2011. 7. 11. · 5/1/2006 Computer Programming TA 103 BE I year 10 Four parts Computer Consists of four parts 1. Hardware

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

Page 2: Welcome to the course of Computer Programming BE I Year · 2011. 7. 11. · 5/1/2006 Computer Programming TA 103 BE I year 10 Four parts Computer Consists of four parts 1. Hardware

Introduction

Minor1 + Minor2 + Quiz1 + Quiz2 + Final

12 + 12 + 8 + 8 + 36= 76

16 Labs + Viva

16 + 8 = 24

Page 3: Welcome to the course of Computer Programming BE I Year · 2011. 7. 11. · 5/1/2006 Computer Programming TA 103 BE I year 10 Four parts Computer Consists of four parts 1. Hardware

5/1/2006 Computer Programming TA 103 BE I year 3

Fundamentals

What is a computer?

Page 4: Welcome to the course of Computer Programming BE I Year · 2011. 7. 11. · 5/1/2006 Computer Programming TA 103 BE I year 10 Four parts Computer Consists of four parts 1. Hardware

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

Page 5: Welcome to the course of Computer Programming BE I Year · 2011. 7. 11. · 5/1/2006 Computer Programming TA 103 BE I year 10 Four parts Computer Consists of four parts 1. Hardware

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

Page 6: Welcome to the course of Computer Programming BE I Year · 2011. 7. 11. · 5/1/2006 Computer Programming TA 103 BE I year 10 Four parts Computer Consists of four parts 1. Hardware

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

Page 7: Welcome to the course of Computer Programming BE I Year · 2011. 7. 11. · 5/1/2006 Computer Programming TA 103 BE I year 10 Four parts Computer Consists of four parts 1. Hardware

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.

Page 8: Welcome to the course of Computer Programming BE I Year · 2011. 7. 11. · 5/1/2006 Computer Programming TA 103 BE I year 10 Four parts Computer Consists of four parts 1. Hardware

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 .

Page 9: Welcome to the course of Computer Programming BE I Year · 2011. 7. 11. · 5/1/2006 Computer Programming TA 103 BE I year 10 Four parts Computer Consists of four parts 1. Hardware

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

Page 10: Welcome to the course of Computer Programming BE I Year · 2011. 7. 11. · 5/1/2006 Computer Programming TA 103 BE I year 10 Four parts Computer Consists of four parts 1. Hardware

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

Page 11: Welcome to the course of Computer Programming BE I Year · 2011. 7. 11. · 5/1/2006 Computer Programming TA 103 BE I year 10 Four parts Computer Consists of four parts 1. Hardware

5/1/2006 Computer Programming TA 103 BE I year 11

Hardware

1. Processor

2. Memory

3. I/O Devices

4. Storage devices

Page 12: Welcome to the course of Computer Programming BE I Year · 2011. 7. 11. · 5/1/2006 Computer Programming TA 103 BE I year 10 Four parts Computer Consists of four parts 1. Hardware

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)

Page 13: Welcome to the course of Computer Programming BE I Year · 2011. 7. 11. · 5/1/2006 Computer Programming TA 103 BE I year 10 Four parts Computer Consists of four parts 1. Hardware

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

Page 14: Welcome to the course of Computer Programming BE I Year · 2011. 7. 11. · 5/1/2006 Computer Programming TA 103 BE I year 10 Four parts Computer Consists of four parts 1. Hardware

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)

Page 15: Welcome to the course of Computer Programming BE I Year · 2011. 7. 11. · 5/1/2006 Computer Programming TA 103 BE I year 10 Four parts Computer Consists of four parts 1. Hardware

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.)

Page 17: Welcome to the course of Computer Programming BE I Year · 2011. 7. 11. · 5/1/2006 Computer Programming TA 103 BE I year 10 Four parts Computer Consists of four parts 1. Hardware

5/1/2006 Computer Programming TA 103 BE I year 17

Floppy CD drive interior Pen or thumb drive

Page 20: Welcome to the course of Computer Programming BE I Year · 2011. 7. 11. · 5/1/2006 Computer Programming TA 103 BE I year 10 Four parts Computer Consists of four parts 1. Hardware

5/1/2006 Computer Programming TA 103 BE I year 20

Babbage’s Difference Engine

1822 ADBabbage’s Analytical

Engine (1833 AD)

Page 21: Welcome to the course of Computer Programming BE I Year · 2011. 7. 11. · 5/1/2006 Computer Programming TA 103 BE I year 10 Four parts Computer Consists of four parts 1. Hardware

5/1/2006 Computer Programming TA 103 BE I year 21

Hollerith’s Card

Reader (1877AD) Mark-I (1937

Page 25: Welcome to the course of Computer Programming BE I Year · 2011. 7. 11. · 5/1/2006 Computer Programming TA 103 BE I year 10 Four parts Computer Consists of four parts 1. Hardware

5/1/2006 Computer Programming TA 103 BE I year 25

IBM 370 (1970) PCs(1977)

Page 26: Welcome to the course of Computer Programming BE I Year · 2011. 7. 11. · 5/1/2006 Computer Programming TA 103 BE I year 10 Four parts Computer Consists of four parts 1. Hardware

5/1/2006 Computer Programming TA 103 BE I year 26

CRAY SV1 (supercomputer) Workstation

Page 27: Welcome to the course of Computer Programming BE I Year · 2011. 7. 11. · 5/1/2006 Computer Programming TA 103 BE I year 10 Four parts Computer Consists of four parts 1. Hardware

5/1/2006 Computer Programming TA 103 BE I year 27

Laptops Handheld computers

Page 28: Welcome to the course of Computer Programming BE I Year · 2011. 7. 11. · 5/1/2006 Computer Programming TA 103 BE I year 10 Four parts Computer Consists of four parts 1. Hardware

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

Page 29: Welcome to the course of Computer Programming BE I Year · 2011. 7. 11. · 5/1/2006 Computer Programming TA 103 BE I year 10 Four parts Computer Consists of four parts 1. Hardware

5/1/2006 Computer Programming TA 103 BE I year 29

KeyBoard Mouse

Page 30: Welcome to the course of Computer Programming BE I Year · 2011. 7. 11. · 5/1/2006 Computer Programming TA 103 BE I year 10 Four parts Computer Consists of four parts 1. Hardware

5/1/2006 Computer Programming TA 103 BE I year 30

Scanner Joy Stick

Page 31: Welcome to the course of Computer Programming BE I Year · 2011. 7. 11. · 5/1/2006 Computer Programming TA 103 BE I year 10 Four parts Computer Consists of four parts 1. Hardware

5/1/2006 Computer Programming TA 103 BE I year 31

Light Pen Web Camera

Page 33: Welcome to the course of Computer Programming BE I Year · 2011. 7. 11. · 5/1/2006 Computer Programming TA 103 BE I year 10 Four parts Computer Consists of four parts 1. Hardware

5/1/2006 Computer Programming TA 103 BE I year 33

Output Devices

Return Processed data back to the user or other computer system

Page 34: Welcome to the course of Computer Programming BE I Year · 2011. 7. 11. · 5/1/2006 Computer Programming TA 103 BE I year 10 Four parts Computer Consists of four parts 1. Hardware

5/1/2006 Computer Programming TA 103 BE I year 34

Laser Printer Ink Jet Printer

Page 35: Welcome to the course of Computer Programming BE I Year · 2011. 7. 11. · 5/1/2006 Computer Programming TA 103 BE I year 10 Four parts Computer Consists of four parts 1. Hardware

5/1/2006 Computer Programming TA 103 BE I year 35

Dot Matrix Printer Line Printer

Page 37: Welcome to the course of Computer Programming BE I Year · 2011. 7. 11. · 5/1/2006 Computer Programming TA 103 BE I year 10 Four parts Computer Consists of four parts 1. Hardware

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.

Page 38: Welcome to the course of Computer Programming BE I Year · 2011. 7. 11. · 5/1/2006 Computer Programming TA 103 BE I year 10 Four parts Computer Consists of four parts 1. Hardware

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)

Page 39: Welcome to the course of Computer Programming BE I Year · 2011. 7. 11. · 5/1/2006 Computer Programming TA 103 BE I year 10 Four parts Computer Consists of four parts 1. Hardware

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.

Page 40: Welcome to the course of Computer Programming BE I Year · 2011. 7. 11. · 5/1/2006 Computer Programming TA 103 BE I year 10 Four parts Computer Consists of four parts 1. Hardware

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.

Page 41: Welcome to the course of Computer Programming BE I Year · 2011. 7. 11. · 5/1/2006 Computer Programming TA 103 BE I year 10 Four parts Computer Consists of four parts 1. Hardware

5/1/2006 Computer Programming TA 103 BE I year 41

Compiler

Compiler : Converts a program from High Level Language to Low level Language

Page 42: Welcome to the course of Computer Programming BE I Year · 2011. 7. 11. · 5/1/2006 Computer Programming TA 103 BE I year 10 Four parts Computer Consists of four parts 1. Hardware

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

Page 44: Welcome to the course of Computer Programming BE I Year · 2011. 7. 11. · 5/1/2006 Computer Programming TA 103 BE I year 10 Four parts Computer Consists of four parts 1. Hardware

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

Page 45: Welcome to the course of Computer Programming BE I Year · 2011. 7. 11. · 5/1/2006 Computer Programming TA 103 BE I year 10 Four parts Computer Consists of four parts 1. Hardware

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

Page 46: Welcome to the course of Computer Programming BE I Year · 2011. 7. 11. · 5/1/2006 Computer Programming TA 103 BE I year 10 Four parts Computer Consists of four parts 1. Hardware

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

Page 47: Welcome to the course of Computer Programming BE I Year · 2011. 7. 11. · 5/1/2006 Computer Programming TA 103 BE I year 10 Four parts Computer Consists of four parts 1. Hardware

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

Page 48: Welcome to the course of Computer Programming BE I Year · 2011. 7. 11. · 5/1/2006 Computer Programming TA 103 BE I year 10 Four parts Computer Consists of four parts 1. Hardware

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

Page 49: Welcome to the course of Computer Programming BE I Year · 2011. 7. 11. · 5/1/2006 Computer Programming TA 103 BE I year 10 Four parts Computer Consists of four parts 1. Hardware

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.

Page 50: Welcome to the course of Computer Programming BE I Year · 2011. 7. 11. · 5/1/2006 Computer Programming TA 103 BE I year 10 Four parts Computer Consists of four parts 1. Hardware

5/1/2006 Computer Programming TA 103 BE I year 50

Flow Chart

Visual Representation of the steps to solve a problem.

Page 51: Welcome to the course of Computer Programming BE I Year · 2011. 7. 11. · 5/1/2006 Computer Programming TA 103 BE I year 10 Four parts Computer Consists of four parts 1. Hardware

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

Page 52: Welcome to the course of Computer Programming BE I Year · 2011. 7. 11. · 5/1/2006 Computer Programming TA 103 BE I year 10 Four parts Computer Consists of four parts 1. Hardware

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

Page 53: Welcome to the course of Computer Programming BE I Year · 2011. 7. 11. · 5/1/2006 Computer Programming TA 103 BE I year 10 Four parts Computer Consists of four parts 1. Hardware

5/1/2006 Computer Programming TA 103 BE I year 53

Questions are welcome !