Lec 01 by rushdulla

VIEWS: 12 PAGES: 33

									Programming Basics 1 1 Tutor : Shaaman Abdulla Masood

What is a Computer? .Computer .Device capable of performing computations and making logical decisions .Computers process data under the control of sets of instructions called computer programs .Hardware .Various devices comprising a computer .Keyboard, screen, mouse, disks, memory, CDROM, and processing units .Software .Programs that run on a computer

2 Tutor : Shaaman Abdulla Masood

Computer Organization .Six logical units in every computer: 1.Input unit .Obtains information from input devices (keyboard, mouse) 2.Output unit .Outputs information (to screen, to printer, to control other devices) 3.Memory unit .Rapid access, low capacity, stores input information 4.Arithmetic and logic unit (ALU) .Performs arithmetic calculations and logic decisions 5.Central processing unit (CPU) .Supervises and coordinates the other sections of the computer 6.Secondary storage unit .Cheap, long-term, high-capacity storage .Stores inactive programs

3 Tutor : Shaaman Abdulla Masood

Hardware Trends .Every year or two the following approximately double: .Amount of memory in which to execute programs .Amount of secondary storage (such as disk storage) .Used to hold programs and data over the longer term .Processor speeds .The speeds at which computers execute their programs

4 Tutor : Shaaman Abdulla Masood

What is Programming .Computer Programming is the art of making a computer do what you want it to do. .At the very simplest level it consists of issuing a sequence of command to achieve an objective 5 Tutor : Shaaman Abdulla Masood

What is Programming .A computer program is simply a set of instructions to tell a computer how to perform a particular task. .Like a recipe: a set of instructions to tell a cook how to make a particular dish. .It describes the ingredients (the data) and the sequence of steps (the process) needed to convert the ingredients into the cake orwhatever. .Programs are very similar in concept. 6 Tutor : Shaaman Abdulla Masood

WhatisProgramming .Just as you speak to a friend in a language so do you 'speak' to the computer in a language. .The only language that the computer understands is called binary. .Binary is unfortunately very difficult for humans to read or write so we have to use an intermediate language and get it translated into binary for us. .This is rather like watching the American and Russian presidents talking at a summit meeting -One speaks in English, then an interpreter repeats what has been said in Russian. .The thing that translates our intermediate language into binary is also called an interpreter 7 Tutor : Shaaman Abdulla Masood

What is Programming .The very first programmers actually had to enter the binary codes themselves, this is known as machine code programming and is incredibly difficult. .The next stage was to create a translator that simply converted English equivalents of the binary codes into binary so that instead of having to remember that the code 001273 05 04 meant add 5 to 4 programmers could now write ADD 5 4. .This very simple improvement made life much simpler and these systems of codes were really the first programming languages, one for each type of computer. .They were known as Assembler languages. 8 Tutor : Shaaman Abdulla Masood

What is Programming .Even this was very primitive, it was still very difficult and took a lot of programming effort to achieve even simple tasks. .Gradually computer scientists developed higher level computer languages to make the job easier. .This was just as well because at the same time users were inventing ever more complex jobs for computers to solve! .This competition between the computer scientists and the users is still going on and new languages keep on appearing. .This makes programming interesting but also makes it important that as a programmer you understand the concepts of programming as well as the pragmatics of doing it in one particular language 9 Tutor : Shaaman Abdulla Masood

Machine Languages, Assembly Languages, and High-level Languages Three types of programming languages 1.Machine languages .Strings of numbers giving machine specific instructions .Example:

+1300042774 +1400593419 +1200274027 2.Assembly languages .English-like abbreviations representing elementary computer operations (translated via assemblers) .Example:

LOAD BASEPAY ADD OVERPAY STORE GROSSPAY 10 Tutor : Shaaman Abdulla Masood

Machine Languages, Assembly Languages, and High-level Languages Three types of programming languages (continued) 3.High-level languages .Codes similar to everyday English .Use mathematical notations (translated via compilers) .Example: .grossPay= basePay+ overTimePay

11 Tutor : Shaaman Abdulla Masood

Structured Programming .Structured programming can be seen as a subset or subdisciplineof procedural programming, .one of the major programming paradigms. .It is most famous for removing or reducing reliance on the GOTO statement. .The process of breaking up a project into small pieces is called as modular design. .Modular programmingis a software design technique that increases the extent to which software is composed from separate parts, called modules. 12 Tutor : Shaaman Abdulla Masood

Structured Programming .The approach in this type of design is top-down i.e. each module is broken down further into sub-sub modules until the whole system is described in detail. .Since all the modules are all described as separate tasks, they can be split among a number of people. .Modules also can be reused. .improve maintainability and easy modification .Each well defined module in a program can be placed in its own program unit. 13 Tutor : Shaaman Abdulla Masood

Programming Language .A programming language is a machine-readable language designed to express computations that can be performed by a computer. .Many programming languages have some form of written specification of their syntaxand semantics, since computers require precisely defined instructions. .Thousands of different programming languages have been created with many more being created every year. .Programming languages differ from most other forms of human expression in that they require a greater degree of precision and completeness 14 Tutor : Shaaman Abdulla Masood

Programming Language .When using a natural language to communicate with other people, human can be ambiguous and make small errors, and still expect their intent to be understood. .However computers "do exactly what they are told to do", and cannot "understand" what code the programmer intended to write. .Each and every operation that your computer performs has instructions that someone had to write in a programming language. These had to be created, compiled and tested-a long and complex task. .An operating system like Microsoft's Windows Vista took millions of man hours to write and test the software. 15 Tutor : Shaaman Abdulla Masood

Activity 1.1 .If you get the opportunity to work with a highly professional, and experienced software develop team. .What type of software would you suggest to develop? 16 Tutor : Shaaman Abdulla Masood

Programming Language .Examples Of Programming Languages: .Assembler .C or C++. .Fortran .Pascal .Operating systems like Linux or Windows are written in C and C++. .Traditional Programming Languages: .Fortran .Cobol .Basic

17 Tutor : Shaaman Abdulla Masood

Programming Language .Current most popular Programming Languages .Java .C++ .C# .C .There have been many attempts to automate this process, and have computers write computer programs but the complexity is such that for now, humans still write the best computer programs. 18 Tutor : Shaaman Abdulla Masood

Programming Language 19 PROG-LAN.gif Tutor : Shaaman Abdulla Masood

What language should I go for ? 20Tutor : Shaaman Abdulla Masood

Programming Language .What do you want to build? .What platform(s) am I going to be running on? .What do I already know? .Does the language have features for my project? 21Tutor : Shaaman Abdulla Masood

Programming Language .For example, FORTRAN is a particularly good language for processing numerical data, but it does not lend itself very well to organizing large programs. .Pascal is very good for writing well-structured and readable programs, but it is not as flexible as the C programming language. .C++ embodies powerful object-oriented features, but it is complex and difficult to learn. 22 Tutor : Shaaman Abdulla Masood

Programming Language .The question of which language is best is one that consumes a lot of time and energy among computer professionals. .Every language has its strengths and weaknesses. .Regardless of what language you use, you eventually need to convert your program into machine language so that the computer can understand it. .There are two ways to do this: .compile the program .interpretthe program

23 Tutor : Shaaman Abdulla Masood

Compilers vs. Interpreters .There are two ways to run programs written in a highlevel language. .The most common is to compile the program; the other method is to pass the program through an interpreter. .An interpreter translates high-level instructions into an intermediate form, which it then executes. .a compiler translates high-level instructions directly into machine language. 24 Tutor : Shaaman Abdulla Masood

Compilers vs. Interpreters .These terms actually refer to two different techniques of generating object code from source code. .It used to be the case that compilers produced object code that could be run on its own (an executable file-another term) whereas an interpreter had to be present to run its program as it went along. .The compileris a program that reads source code, which is the code written by a programmer, and produces an executable or binary file that in a format that can be read and executed (run) by a computer. .The source file is a plain text file containing your code. .The executable file consists of machine code, 1's and 0's that are not meant to be understood or read by people, but only by computers. 25 Tutor : Shaaman Abdulla Masood

Compilers vs. Interpreters .An Interpreter does not need to go through the compilation stage during which machine instructions are generated, which is time-consuming if the program is long. .The main disadvantage of interpreters is that when a program is interpreted, it typically runs more slowly than if it had been compiled. .Compiled programs generally run faster than interpreted programs. 26 Tutor : Shaaman Abdulla Masood

Structured Programming Sequences of instructions: .Here the program flows from one step to the next in strict sequence. 27 Step 1 Step 2 Step 3 Step 4 Tutor : Shaaman Abdulla Masood

Structured Programming Branches: .Here the program reaches a decision point and if the result of the test is true then the program performs the instructions in Path 1, and if false it performs the actions in Path 2. .This is also known as a conditionalconstruct because the program flow is dependent on the result of a test condition. 28 Step 1 Test Condition Path1 Path 2 Tutor : Shaaman Abdulla Masood

Structured Programming Loops: .In this construct the program steps are repeated continuously until some test condition is reached, at which point control then flows past the loop into the next piece of program logic. 29 Test Condition Repeated Steps Tutor : Shaaman Abdulla Masood

Structured Programming Modules: .Here the program performs an identical sequence of actions several times. .For convenience these common actions are placed in a module, which is a kind of mini-program which can be executed from within the main program. .Other names for such a module are: sub-routine, procedure or function. 30 Step 1 Step 2 Step 3 Step 4 Shared Module Tutor : Shaaman Abdulla Masood

Structured Programming .Along with these structures programs also need a few more features to make them useful: 1.Data (Raw Material) 2.Operations (add, subtract, compare etc.) 3.Input/output capability (e.g. to display results) 31Tutor : Shaaman Abdulla Masood

Points to Remember .Programs control the computer .Programming is the art of making a computer do what you want, but what is a program? .Programming languages allow us to 'speak' to the computer at a level that is closer to how humans think .Programs operate on data 32 Tutor : Shaaman Abdulla Masood


								
To top