Top Banner
1.0 INTRODUCTION We know information processing, plays very important role in taking decision every moment. In this context, computers play a significant role in bulk of information processing. Here in this unit, we study what is a computer and architecture of a computer and what are the different program development steps. Computer is an electronic device used to store, retrieve and process data. Data is the unprocessed facts, figures and statistics. Process is the conversion of raw data into useful information. To process data a finite and ordered set of instructions needed. Applications of computer Computers in Business Medicine and Healthcare Education Science Engineering Manufacturing Government Military Entertainment 1.1 COMPUTER ARCHITECTURE (BLOCK DIAGRAM) A computer system consists of hardware and software. Hardware refers to any physical, electrical, electromechnaical components of the computer. For example keyboard, mouse, cabinet of computer is considered as B.V.RAJESH, ASSISTANT PROFESSOR, DEPARTMENT OF IT, SNIST PAGE NO: 1
36

Cp unit 1_2011

Dec 26, 2014

Download

Education

dsaichandu

Download C programming Unit - 1
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Cp unit 1_2011

1.0 INTRODUCTION

We know information processing, plays very important role in taking decision every moment. In this context, computers play a significant role in bulk of information processing. Here in this unit, we study what is a computer and architecture of a computer and what are the different program development steps.

Computer is an electronic device used to store, retrieve and process data. Data is the unprocessed facts, figures and statistics. Process is the conversion of raw data into useful information. To process data a finite and ordered set of instructions needed.

Applications of computer

Computers in Business

Medicine and Healthcare

Education

Science

Engineering

Manufacturing

Government

Military

Entertainment

1.1 COMPUTER ARCHITECTURE (BLOCK DIAGRAM)

A computer system consists of hardware and software. Hardware refers to any physical, electrical, electromechnaical components of the computer. For example keyboard, mouse, cabinet of computer is considered as hardware. Software refers to a program or set of instructions that is written to achieve a specified task.

The figure 1.1 illustrates the block diagram of a computer. It consists of three parts:

1. Input Devices2. Central Processing Unit3. Output Devices

B.V.RAJESH, ASSISTANT PROFESSOR, DEPARTMENT OF IT, SNIST PAGE NO: 1

Page 2: Cp unit 1_2011

Figure 1.1: Block diagram of a computer

1.1.1 INPUT DEVICES

The input device is used to enter data and information into a computer. The devices like keyboard, mouse and scanner are commonly used as input devices.

A keyboard is used to enter alphanumeric characters and symbols. The mouse is used to pick or select a command from the monitor screen. A scanner is used to scan an image or read a barcode and so on.

1.1.2 CENTRAL PROCESSING UNIT

It is the brain of the computer, performs the bulk of the data processing operations. Its main function is to execute programs stored in the main memory by fetching the instructions, examining them and executing them. The program instructions are processed one at a time along with the necessary data. The results are sent to memory and the next instruction is processed. This method is repeated until the program is executed. CPU Consists of 3 functional units: ALU, CU and MU.

B.V.RAJESH, ASSISTANT PROFESSOR, DEPARTMENT OF IT, SNIST PAGE NO: 2

Page 3: Cp unit 1_2011

Arithmetic and Logic unit

The arithmetic-logic unit (ALU) is the unit of the computer that performs arithmetic and logical operations on the data. This section of the machine can be relatively small consisting of circuits and registers which perform arithmetic (+, -, *, /) and logic (>,<,<=,>=,etc) operations.

Arithmetic-logic units which can add and subtract and perform logical operations form the backbone for the arithmetic and control operations in computers. To perform scientific calculations the floating-point number system is used.

Control unit

The control unit controls the overall activities of the components of the computer. It is mainly used to coordinate the activities among other units. It will send commands signals and controls the sequence of instructions to be executed.

The control unit may be defined as “the parts that effect the retrieval of instructions in proper sequence and application of the proper signals to the arithmetic unit and the other parts”. Memory Unit

The memory unit holds data and instructions that are entered through the input unit, before they are processed. It preserves the intermediate and final results before these are sent to the output devices. It also saves the data for the later use. The CPU memory is also called as memory register.

1.1.3 OUTPUT DEVICES

The output device is used to display or print result from a computer. Monitor, printer and plotter are commonly used output devices.

A monitor is used to display the result in the form of text and graphics. The printer is used to print the result. A plotter is used to plot or print graphical result from a computer. Note that a result displayed in a monitor is temporary and it disappears

when the next result is displayed. whereas the output printed using a printer or a plotter is permanent and

these printouts can be used for any business correspondence or documentation.

Normally soft copy is referred to information that is stored on the storage device.

A hard copy refers to a print out showing the information.

B.V.RAJESH, ASSISTANT PROFESSOR, DEPARTMENT OF IT, SNIST PAGE NO: 3

Page 4: Cp unit 1_2011

1.2 COMPUTER SYSTEMS

A computer system consists of hardware and software. Hardware refers to any physical, electrical, electromechnaical components of the computer. For example keyboard, mouse, cabinet of computer is considered as hardware. Software refers to a program or set of instructions that is written to achieve a specified task.

1.2.1 COMPUTER HARDWARE

The hardware component of the computer system consists of: Input devices, Output devices and Processor discussed in 1.1. Memory will be discussed in 1.3.

1.2.2 COMPUTER SOFTWARE

Software is a set of instructions that are used to carry out a task. Software can be grouped into two categories namely application software

and system software. System software manages the computer resources. It provides the

interface between the hardware and the users. Application software, on the other hand, is directly responsible for helping

users solving the problems.

Figure: 1.2 Categories of Software

System Software

System software consists of programs that manage the hardware resources of a computer and perform required information processing tasks.

B.V.RAJESH, ASSISTANT PROFESSOR, DEPARTMENT OF IT, SNIST PAGE NO: 4

Page 5: Cp unit 1_2011

System software is divided in to three categories:

Operating System: consisting of programs and data, this runs on computers and manages the computer hardware. It keeps the system operating in an efficient manner while allowing the users access to the system.

System Support Software: provides system utilities and other operation services. Example disk format programs etc.,

System Development Software: includes the language translators that convert programs in to machine language for execution. Example compiler, assembler.

Application Software

Application Software is divided in to two categories: general-purpose software and application-specific software.

General-purpose software can be used for more than one application, is purchased from software development organizations. Examples include word processor, database management systems, c etc.,

Application-specific software can be used only for its intended purpose. Examples include library automations system etc.,

1.3 MEMORY

Computer memory refers to the physical devices used to store data or programs (sequences of instructions) on a temporary or permanent basis for use in an electronic digital computer.

Computers represent information in binary code, written as sequences of 0s and 1s.

A bit is a binary digit, taking a value of either 0 or 1. A byte is a collection of eight bits.

There are two main types of memory, one is called volatile memory and other is non-volatile memory. Volatile memory: The term volatile memory means that the information present in these types of memory devices is deleted as soon as the power is switched off.

Non-volatile memory: The term non volatile memory means that the information present in these types of memory devices is not lost as soon as the power is switched off.

B.V.RAJESH, ASSISTANT PROFESSOR, DEPARTMENT OF IT, SNIST PAGE NO: 5

Page 6: Cp unit 1_2011

Categories of Memory

Computer memory categorized into the following types

1. Primary memory2. Secondary memory3. Cache memory4. Registers

Figure 1.3 Categories of Memory

1.3.1 PRIMARY MEMORY

Primary memory (main memory) is available in two forms: RAM and ROM.

Random Access Memory

Random Access Memory is a temporary storage medium in a computer. All data to be processed by the computer are transferred from a storage device or keyboard to RAM during data processing. Results obtained from executing any program are also stored in RAM. RAM is a volatile memory.

Two main types of RAM are the Dynamic RAM and the Static RAM. The Dynamic RAM is capacitance-based and cheap, while the Static RAM is switch-based and fast.

RAM consists of many storage cells each of size 1 byte and is identified by using a number called as address or memory location. The memory address is assigned by the computer which also varies from computer to computer and time to time. The data stored in memory are identified using the memory address.

B.V.RAJESH, ASSISTANT PROFESSOR, DEPARTMENT OF IT, SNIST PAGE NO: 6

Page 7: Cp unit 1_2011

ROM (Read Only Memory)

Read Only Memory is a permanent storage medium which stores start up programs. These programs which are loaded when computer is switched on. ROM stores essentially the BIOS (Basic Input Output System) programs which are recorded by the manufacturer of the computer system. ROM is non-volatile memory.

1.3.2 SECONDARY MEMORY

Secondary Memory devices it is used to store data and program on a permanent basis. Secondary Memories are non-volatile in nature. The secondary memory devices are available in huge sizes. It is much slower in speed compared to the internal or the primary memory devices. Examples hard disk, CD ROM, DVD etc.,

1.3.3 CACHE MEMORY

Cache memory is a memory placed between CPU and main memory. It is faster compared to the primary memory. Parts of the program or data that need to be accessed repeatedly are stored in Cache memory.It is a volatile memory.

Internal Cache

It is available internally within the CPU (like the CPU registers). Hence the internal Cache is comparable to the registers in terms of speed but much larger in size compared to the registers.

External Cache

It is available externally along with the CPU, ROM and RAM. These are faster than the RAM and the ROM.

1.3.4 REGISTERS

Registers are small memory units internally available within the processor. It is a volatile memory.

B.V.RAJESH, ASSISTANT PROFESSOR, DEPARTMENT OF IT, SNIST PAGE NO: 7

Page 8: Cp unit 1_2011

1.4 COMPUTING ENVIRONMENT

In the early days of computers, there was only one environment: the mainframe computers hidden in a central computing department. With the advent of personal computers, the environment changed, resulting in computers on everywhere. In this section we will describe different environments.

Personal Computing Environment

In 1971, Marcian E. Hoff, working for Intel, combined the basic elements of the central processing unit into the microprocessor.

If we are using a personal computer, all of the computer hardware components are tied together in our personal computer. In this situation, we have the whole computer for our self: we can do whatever we want. A typical personal computer is shown in Figure 1.4.

Figure 1.4 Personal Computing Environment

Time-Sharing Environment

Employees in large companies often work in what is known as a time-sharing environment. In the time-sharing environment, many users are connected to one or more computers. These computers may be minicomputers or central mainframes. The terminals they use are often nonprogrammable, although today we see more and more microcomputers being used to simulate terminals. Also, in the time-sharing environment, the output and auxiliary storage devices are shared by all users. . A typical personal computer is shown in Figure 1.5.

B.V.RAJESH, ASSISTANT PROFESSOR, DEPARTMENT OF IT, SNIST PAGE NO: 8

Page 9: Cp unit 1_2011

Figure 1.5 Time-sharing Environment

In the time–sharing environment, all computing must be done by the central computer. In other words, the central computer has many duties: It must control the shared resources; it must manage the shared data and printing; and it must do the computing. All of this work tends to keep the computer busy. In fact, it is sometimes so busy that the user becomes frustrated by the computer’s slow responses.

Client / Server Environment

A Client / Server computing environment splits the computing function between a central computer and user’s computers. The users are given personal computers or workstations so that some of the computation responsibility can be moved from the central computer and assigned to the workstations.

In the client/server environment, the user’s microcomputers or workstations are called the Client. The central computer, which may be a powerful microcomputer, minicomputer, or central mainframe system, is known as the server. Because the work is now shared between the users’ computers and the central computer, response time and monitor display are faster and the users are more productive. Figure 1.6 shows a typical client/ server environment.

B.V.RAJESH, ASSISTANT PROFESSOR, DEPARTMENT OF IT, SNIST PAGE NO: 9

Page 10: Cp unit 1_2011

Figure 1.6 The Client/Server Environment

Distributed Computing

A distributed computing environment provided a seamless integration of computing functions between different servers and clients. The Internet provides connectivity to different servers throughout the world. For example, eBay uses several computers to provide its auction service. This environment provides a reliable, scalable, and highly available network. Figure 1.7 shows a distributed computing system.

Figure 1.7 Distributed Computing System.

B.V.RAJESH, ASSISTANT PROFESSOR, DEPARTMENT OF IT, SNIST PAGE NO: 10

Page 11: Cp unit 1_2011

1.5 COMPUTER LANGUAGES

Computer Programming is an art of making a computer to do the required operations, by means of issuing sequence of commands to it.

Categories of Computer Languages

1. Machine Language2. Symbolic Languages3. High-Level Languages

1.5.1 MACHINE LANGUAGES

Machine Language is the only language that is directly understood by the computer. It does not need any translator program. The instructions are called machine instruction (machine code) and it is written as strings of 1's (one) and 0’s (zero). When this sequence of codes is fed in to the computer, it recognizes the code and converts it in to electrical signals.

For example, a program instruction may look like this: 10110001101

Machine language is considered to be the first generation language. Because of it design, machine language is not an easy language to learn. It is also difficult to debug the program written in this language.

Advantage

The program runs faster because no translation is needed. (It is already in machine understandable form)

Disadvantages

It is very difficult to write programs in machine language. The programmer has to know details of hardware to write program

It is difficult to debug the program.

1.5.2 SYMBOLIC LANGUAGE

In Symbolic language, set of mnemonics (symbolic keywords) are used to represent machine codes. Mnemonics are usually combination of words like ADD, SUB and LOAD etc.

B.V.RAJESH, ASSISTANT PROFESSOR, DEPARTMENT OF IT, SNIST PAGE NO: 11

Page 12: Cp unit 1_2011

Assembler

In order to execute the programs written in symbolic language, a translator program is required to translate it to the machine language. This translator program is called Assembler. Later symbolic language known as Assembly language. It is considered to be the second-generation language.

Advantages:

The symbolic keywords are easier to code and saves time and effort It is easier to correct errors and modify programming instructions Assembly Language has utmost the same efficiency of execution as the

machine level language, because there is one-to-one translation between assembly language program and its corresponding machine language program.

Disadvantages:

Assembly languages are machine dependent. A program written for one computer might not run in other computer.

1.5.3 HIGH LEVEL LANGUAGES

High level languages are the simple languages that use English like instructions and mathematical symbols like +, -, %, /, for its program construction. In high level languages, it is enough to know the logic and required instructions for a given problem, irrespective of the type of computer used.

Compiler

Compiler is a translator program which converts a program in high level language in to machine language.

Examples of Higher level languages are: PASCAL, C, ALGOL etc..,

Advantages

High level languages are easy to learn and use

1.6 PROGRAM DEVELOPMENT STEPS

Problem solving is a creative process. It is an act of defining a problem, determining the cause of the problem, identifying, prioritizing, and selecting alternatives for a solution and implementing a solution.

B.V.RAJESH, ASSISTANT PROFESSOR, DEPARTMENT OF IT, SNIST PAGE NO: 12

Page 13: Cp unit 1_2011

A problem can be solved successfully only after making an effort to understand the problem. To understand the problem, the following questions help

What do we know about the problem? What is the information that we have to process in order the find the

solution? What does the solution look like? What sort of special cases exist? How can we recognize that we have found the solution?

It is important to see if there are any similarities between the current problem and other problems that have already been solved. We have to be sure that the past experience does not hinder us in developing new methodology or technique for solving a problem. The important aspect to be considered in problem-solving is the ability to view a problem from a variety of angles.

The various steps involved in Program Development are:

1. Defining or Analyzing the problem2. Design (Algorithm, Flowchart)3. Coding4. Compiling and Running the Program5. Testing and Debugging6. Maintenance&Documenting the program

1.6.1 DEFINING OR ANALYZING THE PROBLEM

The problem is defined by doing a preliminary investigation. Defining a problem helps us to understand the problem clear. It is also known as Program Analysis.

Tasks in defining a problem:

Specifying the input requirements Specifying the output requirements Specifying the processing requirements

Specifying the input requirements

Determine the inputs required and source of the data. The input specification is obtained by answering the following questions:

What specific values will be provided as input to the program? What format will the values be? For each input item, what is the valid range of values that it may assume? What restrictions are placed on the use of these values?

B.V.RAJESH, ASSISTANT PROFESSOR, DEPARTMENT OF IT, SNIST PAGE NO: 13

Page 14: Cp unit 1_2011

Specifying the output requirements

Describe in detail the output that will be produced. The output specification is obtained by answering the following questions:

What values will be produced? What is the format of these values? What specific annotation, headings, or titles are required in the report? What is the amount of output that will be produced?

Specifying the Processing Requirements

Determine the processing requirements for converting the input data to output.

The processing requirement specification is obtained by answering the following questions:

What is the method (technique) required in producing the desired output? What calculations are needed? What are the validation checks that need to be applied to the input data?

LOGIC

A method of human thought that involves thinking in a linear, step by step manner about how a problem can be solved.

Logic is a language for reasoning. It is a collection of rules we use when doing reasoning.

Importance of Logic in problem solving

For solving a problem there may be multiple valid logics some may be simple and others may be complex

For example: Determine whether a given number is prime or not?

Logic 1: Divide the number by all the numbers from 2 to one less than the number and if for all the division operations, the reminder is non zero, the number is prime otherwise it is not prime

Logic 2: Same as logic1 but divide the number only from 2 to the number /2

As a programmer our job is to find out appropriate logic to solve given problem.

B.V.RAJESH, ASSISTANT PROFESSOR, DEPARTMENT OF IT, SNIST PAGE NO: 14

Page 15: Cp unit 1_2011

1.6.2 DESIGN

A design is the path from the problem to a solution in code. Program Design is both a product and a process. The process results in a theoretical framework for describing the effects and consequences of a program as they are related to its development and implementation.

A well designed program is more likely to be:

Easier to read and understand later Less of bugs and errors Easier to extend to add new features Easier to program in the first place

Modular Design

Once the problem is defined clearly, several design methodologies can be applied. An important approach is Top-Down programming design. It is a structured design technique which breaks up the problem into a set of sub-problems called Modules and creates a hierarchical structure of modules.

While applying top-down design to a given problem, consider the following guidelines:

A problem is divided it into smaller logical sub-problems, called Modules Each module should be independent and should have a single task to do Each module can have only one entry point and one exit point, so that the

logic flow of the program is easy to follow When the program is executed, it must be able to move from one module

to the next in sequence, until the last module is executed Each module should be of manageable size, in order to make the design

and testing easier

Advantages

Breaking up the problem into parts helps us to clarify what is to be done. At each step of refinement, the new parts become more focused and,

therefore, easier to design. Modules may be reused. Breaking the problem into parts allows more than one person to work on

the solution simultaneously.

Algorithm (Design technique)

Finite set of steps to accomplish a task Step-by-step, simple, mechanical procedure to compute a function on every possible input.

B.V.RAJESH, ASSISTANT PROFESSOR, DEPARTMENT OF IT, SNIST PAGE NO: 15

Page 16: Cp unit 1_2011

Flowchart

Flowchart is a diagrammatic representation of an algorithm. It uses different symbols to represent the sequence of operations, required to solve a problem.

1.6.3 CODING

An algorithm expressed in programming languages is called Program. Writing a program is called Coding. The logic that has been developed in the algorithm is used to write the program.

1.6.4 COMPILING AND EXECUTING THE PROGRAM

Compilation is a process of translating a source program into machine understandable form. The compiler is system software, which does the translation after examining each instruction for its correctness. The translation results in the creation of object code.

After compilation, Linking is done if necessary. Linking is the process of putting together all the external references (other program files and functions) that are required by the program. The program is now ready for execution. During execution, the executable object code is loaded into the computer’s memory and the program instructions are executed.

1.6.5 TESTING AND DEBUGGING

Testing

Testing is the process of executing a program with the deliberate intent of finding errors. Testing is needed to check whether the expected output matches the actual output. Program should be tested with all possible input data and control conditions.

Testing is done during every phase of program development. Initially, requirements can be tested for its correctness. Then, the design (algorithm, flow charts) can be tested for its exactness and efficiency. Structured walk through is made to verify the design.

Programs are tested with several test criteria and the important ones are given below:

Test whether each and every statement in the program is executed at least once (Basic path testing).

Test whether every branch in the program is traversed at least once (control flow).

B.V.RAJESH, ASSISTANT PROFESSOR, DEPARTMENT OF IT, SNIST PAGE NO: 16

Page 17: Cp unit 1_2011

Test whether the input data flows through the program and is converted to an output (data flow).

Debugging

Debugging is a process of correcting the errors. Programs may have logical errors which cannot be caught during compilation. Debugging is the process of identifying their root causes. One of the ways to ensure the correctness of the program is by printing out the intermediate results at strategic points of computation.

Some programmers use the terms “testing” and “debugging” interchangeably, but careful programmers distinguish between the two activities. Testing means detecting errors. Debugging means diagnosing and correcting the root causes.

On some programs, debugging occupies as much as 50 percent of the total development time. For many programmers, debugging is the hardest part of programming because of improper documentation.

1.6.6 MAINTENANCE AND DOCUMENTING THE PROGRAM

Maintenance

Programs require a continuing process of maintenance and modification to keep pace with changing requirements and implementation technologies. Maintainability and modifiability are essential characteristics of every program.

Documenting the Program

Documentation explains how the program works and how to use the program. Documentation can be of great value, not only to those involved in maintaining or modifying a program, but also to the programmers themselves. Details of particular programs, or particular pieces of programs, are easily forgotten or confused without suitable documentation.

1.7 ALGORITHM

An algorithm is a step-by-step description of the solution to a problem. It is defined as an ordered sequence of well-defined and effective operations which, when carried out for a given set of initial conditions, produce output, and terminate in a finite time. The term “ordered sequence” specifies, after the completion of each step in the algorithm, the next step must be unambiguously defined.

B.V.RAJESH, ASSISTANT PROFESSOR, DEPARTMENT OF IT, SNIST PAGE NO: 17

Page 18: Cp unit 1_2011

1.7.1 PROPERTIES OF AN ALGORITHM

1. Finiteness: Must terminate after a finite number of steps.

2. Definiteness: Action in each step to be carried out must be rigorously and unambiguously specified.

3. Input: Has zero or more inputs that are provided to it initially or dynamically.

4. Output: Has one or more outputs; quantities that have a specified relation to inputs.

5. Effectiveness: operations must all be sufficiently basic.

1.7.2 CATEGORIES OF AN ALGORITHM

Algorithm is mainly divided in to three types.

1. Sequence: A series of steps that we perform one after the other. Steps carried out in given sequence

2. Selection: Making a choice from multiple available options. Next step depends on outcome of condition.

3. Iteration: Performing repetitive tasks. Partial sequence of steps executed repeatedly until condition reached.

1.7.3 DEVELOPING ALGORITHMS

Algorithm development process is a trial-and-error process.

Programmers make initial attempt to the solution and review it, to test its correctness. The errors identified leads to insertions, deletions, or modifications to the existing algorithm.

This refining continues until the programmer is satisfied that, the algorithm is essentially correct and ready to be executed.

The more experience we gain in developing an algorithm, the closer our first attempt will be to a correct solution and the less revision will be required.

However, a novice programmer should not view developing algorithm as a single-step operation.

B.V.RAJESH, ASSISTANT PROFESSOR, DEPARTMENT OF IT, SNIST PAGE NO: 18

Page 19: Cp unit 1_2011

1.6.4 EXAMPLES

Example (sequence)

1. Write an algorithm to find the Area of a Circle.

2. Write an algorithm to add two numbers.

B.V.RAJESH, ASSISTANT PROFESSOR, DEPARTMENT OF IT, SNIST PAGE NO: 19

Aim: Algorithm to find the Area of a Circle

Algorithm:

BEGIN

Step 1: Accept the RADIUSStep 2: Find the square of RADIUS and store it in SQUARE Step 3: Multiply SQUARE with 3.14 and store the result in AREAStep 4: Display AREA

END

Aim: algorithm to find the addition of two numbers.

Algorithm

BEGIN

Step 1: Accept two numbers in A and BStep 2: C = A + BStep 3: Display C

END

Page 20: Cp unit 1_2011

Example (selection)

1. Write an algorithm to find the average marks of a student. Also check whether the student has passed or failed. (Average<35 Fail).

2. Write an Algorithm to find whether a given year is a leap year or not.

1.7 PSEUDO CODE

Pseudo code is an informal high-level description of an algorithm that uses the structural conventions of programming languages, but omits language-specific syntax. It is an outline of a program written in English or the user's natural language.

B.V.RAJESH, ASSISTANT PROFESSOR, DEPARTMENT OF IT, SNIST PAGE NO: 20

Aim: algorithm to find whether student has passed or fail

BEGIN

Step 1: Accept Marks1, Marks2, Marks3Step 2: Total = Marks1 + Marks2 + Marks3Step 3: Average = Total / 3Step 4: if Average < 35 then

Display “Student Failed”else

Display “Student passed”end if

END

Aim: algorithm to find whether a given year is a leap year or not.

Algorithm:

BEGIN

Step 1: Accept the YEARStep 2: if (YEAR %4 == 0) then

Display “Year is a leap year” else

Display “Year is not a leap year” end if

END

Page 21: Cp unit 1_2011

1.8 FLOWCHART

A flowchart is a diagrammatic representation of computation. A flowchart is an organized combination of shapes, lines and text that graphically illustrates a process or structure.

Typical flowchart symbols are given below:

Figure 1.8 Symbols used in flowchart

B.V.RAJESH, ASSISTANT PROFESSOR, DEPARTMENT OF IT, SNIST PAGE NO: 21

Page 22: Cp unit 1_2011

Example (sequence)

1. Draw a flowchart to find the addition of two numbers.

Figure: 1.9 Flowchart to find addition of two numbers

B.V.RAJESH, ASSISTANT PROFESSOR, DEPARTMENT OF IT, SNIST PAGE NO: 22

Start

Accept a, b

C=a + b

Display c

End

Page 23: Cp unit 1_2011

Example (selection)

1. Draw a Flowchart to find the whether a given year is a leap year or not.

False

True

Figure: 1.10 Flowchart to find the given year is leap or not

1.9 SYSTEM DEVELOPMENT (SDLC)

Today’s large-scale projects are built using a series of interrelated phases commonly referred to as the software development life cycle.

Depending on the company and the type of the software being developed, this model consists of between five to seven steps. Figure 1.11 is one possible variation of the sdlc model.

B.V.RAJESH, ASSISTANT PROFESSOR, DEPARTMENT OF IT, SNIST PAGE NO: 23

Start

Accept year

Display leap year

End

if(year%4==0)

Display non leap year

Page 24: Cp unit 1_2011

Sdlc model starts with Requirement. In this phase, the analyst defines the requirements that specify what the proposed project is to accomplish, defines needed information, function, behavior, performance of the proposed project.

Design phase determines how the system will be built. Coding can be done using any programming language consists of

programs. After coding we need to test the project. All the programs are tested

together to make sure the system works as a whole. Final phase, maintenance, keeps the project working once it has put into

production.

Figure: 1.11 Software Development Life Cycle

B.V.RAJESH, ASSISTANT PROFESSOR, DEPARTMENT OF IT, SNIST PAGE NO: 24

Page 25: Cp unit 1_2011

APPENDIX OVERVIEW OF COMPUTER

B.V.RAJESH, ASSISTANT PROFESSOR, DEPARTMENT OF IT, SNIST PAGE NO: 25

Page 26: Cp unit 1_2011

Objective Questions

B.V.RAJESH, ASSISTANT PROFESSOR, DEPARTMENT OF IT, SNIST PAGE NO: 26

Page 27: Cp unit 1_2011

1. Computer systems is made up of [ ]a) Hardware b) Software

c) Both a & b d) None of the above

2. Primary Memory is also called as [ ]a) Auxiliary Memory b) Secondary Storage

c) Soft Copy d) Main memory

3. The terminal (start/stop) in the flow chart is indicated by [ ]a) Parallelogram b) Oval

c) Rectangle d) Diamond

4. A well-defined, finite set of steps to solve a definite nature of the problem is called [ ]a) Algorithm b) Pseudo code

c) Flowchart d) None of the above

5. Input/output in the flow chart is indicated by [ ]a) Parallelogram b) Oval

c) Rectangle d) Diamond

6. Central Processing Unit of the computer system consists of [ ]a) Control Unit b) Arithmetic Logic Unit

c) both a & b d) None of the above

7. Pseudo Code is [ ]a)English like statements b)Problem Solving toolc)Follow a loosely defined syntax d)All of the above

8. The process in the flow chart is [ ]a) Parallelogram b) Oval

c) Rectangle d) Diamond

9. A pictorial representation of an algorithm is called [ ]a) Pseudo Code b) Program

c) Operating System d) Flow Chart

Match the following:

10. RAM a Input Device [ ]11. Plotter b) volatile [ ]12. ROM c) Output Device [ ]13. Key Board d) non-volatile [ ]

ASSIGNMENT I

B.V.RAJESH, ASSISTANT PROFESSOR, DEPARTMENT OF IT, SNIST PAGE NO: 27

Page 28: Cp unit 1_2011

1. Draw the architecture of a computer? Explain.

2. What are the different program development steps? Explain each step in detail.

3. What is an algorithm? What are the different properties and categories of an algorithm? Explain with an example.

4. What is flowchart? What are the different symbols used to draw the flowchart. Explain with an example.

5. Write an algorithm to find the nature of the roots of a quadratic equation.

6. given the 3 sides of triangle a, b and c as input, Draw a flowchart to test whether it is isosceles, equilateral or not. It should also validate whether the input forms a triangle or not. (Ex. 10, 3, 3 is not a triangle)

B.V.RAJESH, ASSISTANT PROFESSOR, DEPARTMENT OF IT, SNIST PAGE NO: 28