Presentation is loading. Please wait.

Presentation is loading. Please wait.

Senem Kumova Metin 2010-2011 Introduction to Programming CS 115 Introduction to Computing PART I : Computer Basics PART II: Introduction to Computing/Programming.

Similar presentations


Presentation on theme: "Senem Kumova Metin 2010-2011 Introduction to Programming CS 115 Introduction to Computing PART I : Computer Basics PART II: Introduction to Computing/Programming."— Presentation transcript:

1 Senem Kumova Metin Introduction to Programming CS 115 Introduction to Computing PART I : Computer Basics PART II: Introduction to Computing/Programming

2 Senem Kumova Metin PART I : Computer Basics Contents Computer basics Hardware & software Hardware components

3 Senem Kumova Metin What is a Computer? A computer is a machine that manipulates data according to a list of instructions Simply a computer 1. takes information (or inputs) 2. processes it according to a set of instructions (a program) 3. gives back a result (or output)

4 Senem Kumova Metin Computing Activity of using and developing computer technology, computer hardware and software. Hardware –a general term that refers to the physical artifacts of a technology Software –a general term used to describe a collection of computer programs, procedures and documentation that perform some tasks on a computer system

5 Senem Kumova Metin Key components of a Computer

6 Senem Kumova Metin Key components of a Computer Input Devices –Receiving sections of computer –Allow the user to control the machine –Examples : Keyboard Mouse Microphone Scanner Etc..

7 Senem Kumova Metin Key components of a Computer Output Devices –Return the results of computer actions back to the user –Examples : Monitor Speakers Printer

8 Senem Kumova Metin Key components of a Computer CPU ( Central Processing Unit) –‘brain’ of the computer –Follows the instructions provided by both the user (via input devices) and the program that is running in order to perform a task – Involves a control unit, ALU (Arithmetic Logic Unit), registers...

9 Senem Kumova Metin Key components of a Computer Memory –Internal storage areas in the computer –Retains information that has been entered through the input unit so that the information may be made available for processing when needed. –RAM and ROM RAM - Random access memory: whose contents can be accessed (read, write and remove) in any order ROM - Read-only memory: On ROM, data is prerecorded for read only which can not be removed

10 Senem Kumova Metin Key components of a Computer Secondary Storage –Long term high capacity warehousing part of the computer –Store both the programs that run on the system as well as the work that is created –The most common storage device is a fixed magnetic disk that sits inside the machine and this is called the hard drive –Examples: hard disk, CD,DVD and flash drives

11 Senem Kumova Metin PART II : Introduction to Computing/Programming Contents Computer programming Flow of Control Programming languages Programming in C

12 Senem Kumova Metin WHAT is PROGRAMMING?? scheduling or performing a task or / and event WHAT is COMPUTER PROGRAMMING?? creating a sequence of steps for a computer to follow in performing a task

13 Senem Kumova Metin WHAT is a PROGRAMMING LANGUAGE ? A set of rules, symbols, and special words used to construct a computer program

14 Senem Kumova Metin Programming language rules consist of –Rules of Syntax which specify how valid instructions are written in the language ( natural language rule  subject + verb +object ) –Rules of Semantics which determine the meaning of the instructions (what the computer will do) ( A book has bitten a car )

15 Senem Kumova Metin Programming Languages Machine Languages Assembly Languages High Level Languages

16 Senem Kumova Metin Machine Language Machine dependent Machine code is a set of instructions that a computer's central processing unit (CPU) can understand and obey directly, without any translation. Machine-code programs consist entirely of binary digits (bits). BIT ?? BYTE??

17 Senem Kumova Metin Assembly Language First attempt at producing a mechanism for writing programs that was more palatable to ourselves A program written in assembly code, in order to “run”, must first be translated (assembled) into machine code.

18 Senem Kumova Metin High Level Languages A more problem-oriented (rather than machine-oriented) mechanism for creating computer programs would also be desirable Hence the advent of high(er) level languages starts with the introduction of “Autocodes”, and going on to Algol, Fortran, Pascal, Basic, Ada, C, etc Interpreted or compiled

19 Senem Kumova Metin Machine Language Assembly Language Load basePay Add overTimePay Store grossPay High level Language grossPay= basePay+overTimePay

20 Classification of High level Programming languages Programming paradigm : Alternative approaches to the programming process –Functional (Lisp, ML) –Object-Oriented (C++, Java) –Imperative (Procedural) (Fortran, Algol, Pascal, Basic, C) –Declarative (Prolog,GPSS) Senem Kumova Metin

21 High Level Languages Interpreted –Interpreted Languages are read and then executed directly, with no compilation stage. Compiled –Compiled Languages are transformed into an executable form before running.

22 Senem Kumova Metin ASSEMBLY versus HIGH LEVEL LANGUAGE HelloWorld.asm Source Code HelloWorld.c Source Code Machine Code (binary) Object Code assembled compiled Library (stdio.h) linked

23 Senem Kumova Metin Compilation Process

24 Senem Kumova Metin High Level Languages: Libraries Libraries (in computer programming terms) contain chunks of precompiled (object) code for various functions and procedures that come with a programming language that requires compilation For example functions and procedures to facilitate I/O

25 Senem Kumova Metin Flow of Control The execution sequence of a group of machine instructions is known as the flow of control.

26 Senem Kumova Metin EXAMPLE 1: Flow of Control SCENARIO : we have 2 integers : x, y multiply x with y store the result in x print the value of x int x and int y x = x*y print x

27 Senem Kumova Metin EXAMPLE 2: Flow of Control SCENARIO : we have 2 integers : x,y if x is greater than 0 then do x= y+1; else do x= y-1; print the value of x int x and int y x > 0 YESNO x = y+1 x = y-1 print x

28 Senem Kumova Metin Why C? Native language of UNIX (a famous operating system) Standard development language for personal computers Portable (can be moved to other machine !) Powerful set of operators and powerful libraries (some operators: ++,--….) Basis for Java, C++…..

29 Senem Kumova Metin First C program – Basic I/O functions : printf / scanf – Including libraries – Writing comments – Defining variables ….

30 Senem Kumova Metin Basic I/O Functions: printf #include // library file void main(void) { printf("from sea to shining C\n"); } // Print a string of characters to the screen

31 Senem Kumova Metin Basic I/O Functions: printf #include void main(void) { printf("from sea ”); printf(“to shining C\n"); }

32 Senem Kumova Metin Basic I/O Functions && Defining a variable #include // library file void main(void) { int x=0; // an integer variable is defined and it is // initialized to 0 printf(“%d“, x); // print current value of variable x as a decimal value }

33 Senem Kumova Metin Basic I/O Functions : scanf #include void main(void) { int x=0; printf(“%d\n”, x); // print x as a decimal value scanf(“%d”,&x); // read a decimal value from keyboard, store it in x printf(“%d\n”, x); // print x as a decimal value }


Download ppt "Senem Kumova Metin 2010-2011 Introduction to Programming CS 115 Introduction to Computing PART I : Computer Basics PART II: Introduction to Computing/Programming."

Similar presentations


Ads by Google