35
CSC240 INTRODUCTION TO PROGRAMMING – I Mr. Dilawar Lecturer, Department of Computer Science, Jahan University Kabul, Afghanistan.

Csc240 lecture 1

Embed Size (px)

Citation preview

Page 1: Csc240   lecture 1

CSC240INTRODUCTION TO PROGRAMMING – I

Mr. Dilawar

Lecturer,Department of Computer Science,

Jahan UniversityKabul, Afghanistan.

Page 2: Csc240   lecture 1

Course Objectives• After successfully completing this course, you will be able to:

• What is a computer system and how it works.• Flow charts and Algorithms.• Computer programming concepts and their implementation in C++ language.

Page 3: Csc240   lecture 1

Course Outline• Introduction to Computer and Programming Languages.

• Elements of C++ Language.

• Control Structures.

• Working and Understanding Arrays.

• Working with Structures, Union and Enumeration.

Page 4: Csc240   lecture 1

Text Books to Follow• Dietal & Dietal, C/C++: How to Program 7th Edition.

• Programming with C++ by CM Aslam & TA Qureshi (Aikmen Series).

• Object oriented programming using C++ by IT Series.

Page 5: Csc240   lecture 1

Lecture Outline• Introduction to computers and computer organization

• Personal, Distributed and Client/Server Computing

• Programming languages

• Components of programming languages

• Programming techniques

Page 6: Csc240   lecture 1

Introduction to Computer• An electronic machine that can perform computations and logical

decisions at a speed of millions and even billions of times faster than human being.

• Processes data under control sets of instructions called program.

• A program is a set of instructions that is used to perform a specific task.

• Programs are written by programmer.

• Programming Languages are the source through which a programmer writes and develops computer programs.

Page 7: Csc240   lecture 1

Introduction to Computer• Computers are comprised of two parts:

• Hardware- • Software

HardwareElectronics circuit boards

that provide functionality of the system

SoftwareProgram consists

of sets of instructionsthat control the system

Page 8: Csc240   lecture 1

Computer Organization

Control Unit

Datapath

Arithmetic Logic Unit

(ALU)

Registers

Processor (CPU)

Page 9: Csc240   lecture 1

Computer Organization• Input Unit

• Receiving section of the computer.• Gets data from various devices and places.• Data is entered into computer with the help of mouse & keyboard.• Data can also be entered in the form of voice and images via scanner and

microphone.

Page 10: Csc240   lecture 1

Computer Organization• Output Unit

• Shaping section of the computer.• Takes information from CPU and places it on various output devices.• Information can be viewed either on screens or printed papers.

Page 11: Csc240   lecture 1

Computer Organization• Memory Unit

• Short time warehouse section of computer.• It keeps the data that has been entered so that it can be available for

processing.• It also keeps the processed data so that information can be placed on output

devices by output unit.

Page 12: Csc240   lecture 1

Computer Organization• Arithmetic & Logic Unit

• Manufacturing section of computer.• It is responsible for calculations and logical operations.• Calculation involves addition, subtraction, multiplication and division.

Page 13: Csc240   lecture 1

Computer Organization• Control Unit

• Administrative section of computer.• It supervises the operations of the other sections.• It control and allocates jobs for all other units.• Many of today’s computers have multiple CPUs and, hence, can perform

many operations simultaneously – multicore processors.• Dual-core processors – Two CPU’s

• Quad-core processors – Four CPU’s

Page 14: Csc240   lecture 1

Computer Organization• Registers

• Storage location in CPU, used to hold data or a memory address during the execution of an instruction.

Page 15: Csc240   lecture 1

Computer Organization• Secondary Unit

• Long time warehouse section of computer• Program and data that are not actively used by the other units are normally

placed on secondary storage time.• It stores the data permanently for future time.• Non-Volatile Memory

Page 16: Csc240   lecture 1

Personal, Distributed and Client/Server Computing• Using desktop and laptop computers for personal use – Personal

computing.

• In 1977, Apple computer popularized Personal computing.

• In 1981, IBM the world’s largest computer vender, introduced the IBM Personal Computer.

• Stand-alone – transported disks back and forth between them – Sneakernet.

Page 17: Csc240   lecture 1

Personal, Distributed and Client/Server Computing• Machines could be linked together in computer networks, over

telephone lines in LANs that led to the phenomenon of distributed computing.

• Distributed computing is a model in which components of a software system are shared among multiple computers to improve efficiency and performance.

Page 18: Csc240   lecture 1

Personal, Distributed and Client/Server Computing• In Client/Server computing:

• Servers provides services such as file servers, database servers, web servers and etc…

• Client computers uses the services provided by the server.

Page 19: Csc240   lecture 1

Programming Languages• A programming language is used to write computer programs.

• It is an artificial language designed to communicate instructions to a machine.

• Some of them are directly understandable by computer and some of them are needed to be converted first.

Page 20: Csc240   lecture 1

Programming Languages• Computer languages are divided into three broad types:

• Machine Language• Assembly Language• High-Level Language

Page 21: Csc240   lecture 1

Programming Languages• Machine Languages

• A computer understands machine language.• Machine language is also called binary language.• It is consist of two digits that instructs computers to perform their operations.• They are machine-dependent.• No translation is required – directly understandable by computer.• They are hard to learn and understand.

Page 22: Csc240   lecture 1

Programming Languages

Page 23: Csc240   lecture 1

Programming Languages• Assembly Language

• A language in which instead of binary codes we use English like abbreviations (mnemonics) to represent the operations for the computer.

• A language that uses symbolic names to represent operations, registers and memory locations.

• It uses a translator called Assembler.

Page 24: Csc240   lecture 1

Programming Languages

Page 25: Csc240   lecture 1

Programming Languages• High-Level Language

• A language in which the instructions are written in the form of everyday English and contain commonly used mathematical notations.

• Compiler and Interpreter are used to covert the high-level code to machine code.

Page 26: Csc240   lecture 1

Programming Languages

Page 27: Csc240   lecture 1

Programming Languages

Hierarchy of Languages

Language Representations

Page 28: Csc240   lecture 1

Components of Programming Languages• Syntax

• It is about the structure of the grammar of the language.• In programming language, the rules and regulations for writing code are

called the syntax.• A syntax can be used to construct a valid sentence/statement.

Page 29: Csc240   lecture 1

Components of Programming Languages• Semantic

• It describes the meaning of the sentence.• It describes that whether the sentence is correct or not. If so, what does the

sentence mean?

Page 30: Csc240   lecture 1

Categories of Programming Languages• Major programming languages falls in the category of:

• Structured Programming Languages• Modular Programming Languages• Object-Oriented Programming Languages

Page 31: Csc240   lecture 1

Categories of Programming Languages• Structured Programming Languages

• Languages in which the program is divided into smaller components – functions.

• The structured programming contains three major concepts that are:• Top-down Design / Divide and Conquer

• Code Reusability

• Information Hiding

Page 32: Csc240   lecture 1

Categories of Programming Languages• Modular Programming Languages

• Languages in which the program is broken into individual components called modules that can be programmed and tested independently.

Page 33: Csc240   lecture 1

Categories of Programming Languages• Object-Oriented Programming Languages

• Languages in which object technology is supported.• It allows the pieces of software to be reused and interchanged between

programs.• The major concepts used in OOP are:

• Data Abstraction – Describes user defined datatypes.

• Encapsulation – Information Hiding

• Inheritance – Describes the reusability of a class.

• Polymorphism – Describes the ability to produce different results based on the object that is sent to.

Page 34: Csc240   lecture 1

Summery• Introduction to computers and computer organization

• Personal, distributed, and client/server computing

• Programming languages

• Components of programming languages

• Categories of programming languages

Page 35: Csc240   lecture 1

Thank YouFor your Patience