You are on page 1of 55

Unit - I

1. Computer fundamentals i. computer systems ii. Computer hardware iii. Computer software 2. computer environments i. Personal computing environment ii. Time- sharing environment iii. Client/server environment iv. Distributed environment.
10/03/12 S.Durga Devi 1

What is a computer?
A computer is a programmable machine. It allows the user to store all sorts of information and then process that information or carry out actions with the information such as calculating numbers or organizing words

10/03/12

S.Durga Devi

VON NEUMANN ARCHITECTURE

Computer systems
Computer is a system made up of two components hardware and software.

10/03/12

S.Durga Devi

The physical equipments required to create, use, manipulate and store electronic data. Hardware consist of five parts- input devices, cpu (central processing unit ), output devices, memory, storage devices.

Computer hardware

10/03/12

S.Durga Devi

Computer hardware
1. Input devices- keyboard, mouse, scanner, pen drive, touch screen. 2. CPU ( central processing unit)- enable to process data also known as a processor. 3. out put devices- monitor, printer, external disks. If output shown on the screen is the soft copy. If it is printed on the paper is called hard copy. 4. memory it is a part of the computer used to hold the waiting data to be processed. 5. storage devices- place where computer stores the data. these are two storage devices- primary storage or main memory. - main memory- this is the place where data stored temporarily during processing. Ex- RAM ( Random Access Memory) the data stored on the main memory is erased when the computer is turned off. - auxiliary storage- also known as secondary storage this is the place where data to be stored permanently
10/03/12 S.Durga Devi 6

Computer software
Software is the computerized instructions that operate the computer, execute particular functions or tasks, and manipulate the data. These instructions need to be written in a programming language that the computer can understand.

Programming language- An artificial set of rules vocabulary and syntax used to instruct the computer to execute certain tasks.

10/03/12

S.Durga Devi

Computer software

10/03/12

S.Durga Devi

System software
System software manage the hardware resources of a computer and perform the processing. 1. operating system computer must have operating system in order to run the other programs. 2. System support software provides all the utilities that enable the computer to function. Ex:- sort programs and disk formatting. 3.System development software this includes language translators used convert into machine language for execution, debugging tools to ensure that the programs are
10/03/12

error- free.Ex- compilers.S.Durga Devi

Application software
1. General purpose software same software used for several purposes ex- word processor, DBMS, CAD 2. Application specific software a software is used only for the particular task for which it is designed. ex- Internet explorer, anti virus, media player.

10/03/12

S.Durga Devi

10

GURE 1-4 Relationship between system and application software


11

Computing environment
1. 2. 3. 4. Personal computing environment Time sharing environment Client\server environment Distributed environment

1. Personal computing environment

Fig: Personal computing environment ->In this environment a single personal computer is maintained to which all the computer hardware components are tied together. ->This computer is used by our self. We can do whatever you want. In this environment no need of server. It is like an individual pc for each individual user.

2. Time sharing environment


In the time sharing environment many users are connected to one or more computers. -> the output devices like printers and auxiliary storage devices Are shared by all the users. ->ex:- in college lab mini computer is shared by all the Students. -> in which all computing must done by the central computer. -> shared resources are connected to central computer so that it must Control the shared resources. -> it must manage the shared data and printing. Always keeps the computer busty.

FIG- Time-sharing Environment

3. client\server environment

-> all the computing functions are shared between the central computer and users computers. -> the users are given personal computer or work station which are known as clients -> the central computer is called server. -> this environment much faster than the time sharing environment as the work shared between the user computers and the server.

4. Distributed computing

-> It is the integration of different clients and different servers. ex- internet. -> the connectivity between these different users and different servers provided by internet through out the world.

Computer languages
A program for the computer must be written in programming language. The first programming language is machine language. computer languages were evolved from machine language to natural language ( english like language).

Machine language
Machine language was the first programming language in the early days of computers. The language which is understand by the computer hardware is called machine language. It consists of 0s and 1s. Internally the computer consists of circuits which are made of switches, transistors and other electronic devices that can be in one of the two states: off or on. Off- 0, on- 1.

FIG Computer Language Evolution

PROGRAM 1-1 The Multiplication Program in Machine Language

Symbolic language
Writing program in machine language is difficult. The language is represented in symbols or mnemonics so it is called symbolic language. This is language does not understand by the computer .hence, it must be translated to the machine language using the assembler. Another name of the symbolic language is assembly language.

PROGRAM 1-2

High level languages


It is like natural language which can understand by the programmer. They must be converted into the machine language is called compilation. First high level language is FORTRAN High level languages are c, c++, java, cobol etc

PROGRAM 1-3 The Multiplication Program in C

continued

PROGRAM 1-3 The Multiplication Program in C (continued)

Creating and Running Programs Creating and running programs takes place in 4 steps. 1. writing and editing the program. 2. compiling. 3. linking the program with the required library functions. 4. executing the program.

FIG- Building a C Program

1. writing and editing the program


Software used to write programs is known as a text editor, where we can type, edit, store character data. Text editor which includes compilers, we complete a program and save file on to the disk with .c extension. This file is called source file.

2. Compiling program
The source file on disk must be converted to machine language using the special software called compilers. It could complete its task in two steps. i) preprocessor ii) translator i) preprocessor- preprocessor reads source file and checks for special commands known as preprocessor commands ( instructions which are starts with # symbols ). The resultant of preprocessor is called translation unit. Another point about preprocessor is it processes the source file before compilation. ii) Translator- translator is a program which converts the program into machine language and gives the object modules. This module not yet ready to run because it not yet include other special functions.

3. linking the program with the required library functions


C program made up of different functions in which some functions can written by programmer and other functions like input/output processes and mathematical library functions are included in compiler else where those must be attached to our program. The linker assembles all of these functions and produces the executable file which is ready to run on the computer.

4. executing the program.


Now, operating system is responsible to run the program which uses the run command. It loads the program from the disk to main memory is called loader.

Writing and Running Programs


#include <stdio.h> /* The simplest C Program */ int main(int argc, char **argv) { printf(Hello World\n); return 0; }

1. Write text of program (source code) using an editor such as TC, save as file e.g. my_program.c

2. Run the compiler to convert program from source to an executable or binary: ALT + F9 my_program.obj
$ gcc -Wall g my_program.c o my_program tt.c: In function `main': tt.c:6: parse error before `x' tt.c:5: parm types given both in parmlist and separately tt.c:8: `x' undeclared (first use in this function) tt.c:8: (Each undeclared identifier is reported only once tt.c:8: for each function it appears in.) tt.c:10: warning: control reaches end of non-void function tt.c: At top level: tt.c:11: parse error before `return'

3. Compiler gives errors and warnings; edit source file, fix it, and re-compile 4. Run it and see if it works CTRL + F9 C:>/my_program Hello World C:>

(ALT + F5)
What if it doesnt work?

my_program

System Development life cycle


Weve now seen the steps that are necessary to build a program. In this section, we discuss how we go about developing a program. This critical process determines the overall quality and success of our program. If we carefully design each program using good structured development techniques, our programs will be efficient, error-free, and easy to maintain. -> the software development is the translation of user need or marketing goal into a software product is called software development life cycle. -> sofware development life cycle is a frame work that is used to structure, plan and control the process of developing an information system. -> there are several software development techniques among them waterfall method is one of the famous methodology.

Water fall model has 6 phases.

FIG- Waterfall Model

1. System requirements- if programmer knows what exactly customer wants then he can develop the project. The experienced and skilled persons recognize the requirements from the client. 2. Analysis- looks at different alternatives from the system point of veiw. 3. Design- what are inputs required and how they are converted into outputs and also design the flowchart or algorithm for the program. 4. Coding- implement the program using computer programming languages. 5. Testing- the project is gone under the testing and make sure that project works well without any errors.

Program Dvelopment

1.Understand the problem 2.Develop solution 1.Structure Chart 2.Algorithm/pseudocode 3.Flowchat 3.Write the program 4.Test the program

36

Understand the problem


To solve any problem first we must understand the problem by knowing the requirements of the problem. Once we understand it, review with user(customer) and system analyst.

10/03/12

S.Durga Devi

37

Develop the solution


To develop a solution to a problem it needs three tools. 1.Structure chart- the functional flow through our program. Shows how the problem is broken into logical steps. Each step will be a separate module. 2.Algorithm 3.flowchart
10/03/12 S.Durga Devi 38

Buy a computer

Get configurati on

calculate

Print report

desktop

Laptop

DELL

hp

DELL

hp

10/03/12

S.Durga Devi

39

Algorithm or pseudo code


Definition of algorithm- Al Kho-war-iz-mi an ordered sequence of unambiguous and well-defined instructions that performs some task and halts in finite time Let's examine the four parts of this definition more closely. 1. Ordered sequence- we can number the step. 2. Unambiguous and well defined instructions- each instruction is clear, understand without difficulty. 3. Performs some task 4. Halts in finite time- algorithm must terminate at some point. Algorithms can be executed by a computing agent which is 10/03/12 necessarily a computer. S.Durga Devi 40 not

Properties of an algorithm:Finiteness

:- An algorithm must terminate in a finite number of steps. Definiteness :- Each step of the algorithm must be precisely and unambiguously stated. Effectiveness:-Each step must be effective, and can be performed exactly in a finite amount of time. Generality :- The algorithm must be complete in itself. Input/Output :- Each algorithm must take zero, one or more inputs and produces one or more output.

How to represent an algorithm


1. use natural language- English 2. use formal programming language. 3. pseudo code- natural language constructs modeled looks like statements available in the programming language. Pseudo code- an algorithm written in english like language is called pseudo code. Pseudo code is a numbered list of instructions to perform a task.
10/03/12 S.Durga Devi 42

Examples: 1.. If student's grade is greater than or equal to 60 1.1 Print "passed" 2 else 2.1 Print "failed"

10/03/12

S.Durga Devi

43

Multiplying two numbers


1. declare a, b, c. 2. enter two numbers a and b 3.a=10, b-=20 4. c= a*b; 5. display c.

10/03/12

S.Durga Devi

44

Three Categories of Algorithmic Operations An algorithm must have the ability to alter the order of its instructions. An instruction that alters the order of an algorithm is called a control structure Three Categories of Algorithmic Operations: 1. sequential operations - instructions are executed in order 2. Conditional/selection ("question asking") operations - a control structure that asks a true/false question and then selects the next instruction based on the answer 3. iterative operations (loops) - a control structure that 10/03/12 S.Durga block of instructions 45 repeats the execution of aDevi

Example - Computing a Quiz Average: Pseudo-code a routine to calculate your quiz average. 1. get number of quizzes 2. sum = 0 3. count = 0 4. while count < number of quizzes 4.1 get quiz grade 4.2 sum = sum + quiz grade 4.3 count = count + 1 5. average = sum / number of quizzes 6. display average 7. halt variables: number of quizzes, sum ,count, quiz grade, average This example introduces an iterative control statement. As long as the condition in line 4 is True, we execute the subordinate operations 4.1 - 4.3. When the condition becomes False, we resume the pseudo-code at line 5.
10/03/12 S.Durga Devi 46

Pseudo-code Language Constructions : A Summary Computation/Assignment set\initialize the value of "variable" to :"arithmetic expression" or "variable" equals "expression" or "variable" = "expression" Input/Output get \enter\read "variable", "variable", ... Display\print "variable", "variable", ... Conditional (dot notation used for numbering subordinate statements) 6. if "condition" 6.1 (subordinate) statement 1 6.2 etc ... 7. else 7.1 (subordinate) statement 2 7.2 etc ... Iterative (dot notation used for numbering subordinate statements) 9. while "condition" 9.1 (subordinate) statement 1 9.2 etc ...
10/03/12 S.Durga Devi 47

Pseudo code consists of readable and formally-styled natural language used to explain specific tasks within a program's algorithm while an Algorithm is a set of instructions used to solve a particular problem. First produce a general algorithm (one can use pseudo code) Redefine the algorithm successively to get step by step detailed algorithm that is very close to a computer language.

10/03/12

S.Durga Devi

48

Flow chart
Pictorial representation of an algorithm is called flow chart. A flow chart is a graphical or symbolic representation of a process. A diagram that uses graphic symbols to depict the nature and flow of the steps in a process. Snap shot of an algorithm.

10/03/12

S.Durga Devi

49

The Flowchart
A Flowchart
shows logic of an algorithm emphasizes individual steps and their interconnections Shows flow of execution of the algorithm. e.g. control flow from one action to the next

SYMBOLS USED WITH FLOWCHARTS


NAME Terminal Input/output Process Decision Making connector Flow Direction
51

SYMBOL
oval parallelogram

PURPOSE
Beginning and ending of flow chart Input/output data Mathematical calculations, data transfer, logical operations Alternate path Transfer to another point in a flow chart or next page. Path of a logical flow in a program.

Rectangle

diamond circle

Pseudo code & Algorithm


Example 1: Write an algorithm to determine a students final grade and indicate whether it is passing or failing. The final grade is calculated as the average of four marks.

Pseudo code & Algorithm


Pseudo code: Input a set of 4 marks Calculate their average by summing and dividing by 4 if average is below 50 Print FAIL else Print PASS

Pseudo code & Algorithm


Detailed Algorithm Step 1: Input M1,M2,M3,M4 Step 2: GRADE (M1+M2+M3+M4)/4 Step 3: if (GRADE < 50) then Print FAIL else Print PASS endif

1. sum of the digits of a number. 2. nature of quadratic equations. 3. income tax problem. 4. standard deviation. 5. fibonacci sequence and golden ratio 6. towers of hanoi.

You might also like