Monday, September 27, 2010

Flowcharts

WHAT IS A FLOWCHART?:

It is an organized combination of shapes, lines and text which graphically illustrate a process.
  • A flowchart can be used as an alternative for an algorithm
SYMBOLS USED IN FLOWCHARTS:

The following table shows a listing of different symbols used in flowcharts along with their meaning and purpose –

EXAMPLES:

1. Draw a flowchart to print the sum of two numbers.
2.  Draw a flowchart to print the average of any three numbers.
3. Draw a flowchart to print Area and Perimeter of a Square.
4. Draw a flowchart to print biggest of two numbers.
5. Draw a flowchart to check whether a number is positive, negative or zero.
6. Draw a flowchart to print biggest of three numbers.
7. Draw a flowchart to print a number ‘n’ 10 times.
8. Draw a flowchart to print all the odd numbers between 1 and n.
9. Draw a flowchart to print all the even numbers between 1 and n.

Algorithms

USING ALGORITHMS TO SOLVE PROBLEMS:

What is an Algorithm?
An algorithm is a step-by-step procedure to solve a given problem.
Steps in algorithm writing:
Ø  Identify all the inputs and outputs required for solving a problem.
Ø  Identify additional data and constants needed.
Ø  Computation steps
Ø  Print / Display all the required results.

DIFFERENT PATTERNS IN ALGORITHMS:
There are mainly three different patterns of algorithms. They are as listed below-
  1. Sequential – The steps represent sequence of occurrence of processing.
  2. Conditional – Based on one or more conditions the instructions are divided
  3. Iterational – Same set of instructions are repeated more than once until an end condition. These are also called Repetitive patterns.



EXAMPLES:
A. On Sequential Patterns
1.    Write an algorithm to find the sum of any two numbers.
Sol-                 Step 1: Start
                        Step 2: Read two numbers n1 and n2
                        Step 3: Sum = n1 + n2
                        Step 4: Print ‘Sum’
                        Step 5: Stop

2.    Write an algorithm to find the average of three numbers.
Sol-                 Step 1: Start
                        Step 2: Read three numbers n1, n2 and n3
                        Step 3: Avg = (n1 + n2 + n3) /3
                        Step 4: Print ‘Avg’
                        Step 5: Stop

3.    Write an algorithm to find the volume of a cylinder.
Sol-                 Step 1: Start
                        Step 2: Read radius (r) and height (h)
                        Step 3: Initialize constant,  P = 3.142
                        Step 4: Volume = Pr2h
                        Step 5: Print ‘Volume’
                        Step 6: Stop

4.    Write an algorithm to find the area and perimeter of a square.
Sol-                 Step 1: Start
                        Step 2: Read side of a square (a)
                        Step 3: Area = a2      and     Perimeter = 4a
                        Step 4: Print ‘Area’ and ‘Perimeter’
                        Step 5: Stop

5.    Write an algorithm to convert celcius into farenheit.
Sol-                 Step 1: Start
                        Step 2: Read temperature in celsius (c)
                        Step 3: f = 9c / 5 + 32
                        Step 4: Print temperature in farenheit (f)
                        Step 5: Stop

B. On Conditional Patterns
1.    Write an algorithm to find biggest of two numbers.
Sol-                 Step 1: Start
                        Step 2: Read two numbers (n1 and n2)
                        Step 3: if n1 > n2, go to Step 5
                        Step 4: Print “n2 is biggest” and go to Step 6
                        Step 5: Print “n1 is biggest”
                        Step 6: Stop

2.    Write an algorithm to check whether a given number is +ve, -ve or a zero.
Sol-                 Step 1: Start
                        Step 2: Read a number (n)
                        Step 3: if n > 0, go to Step 6
                        Step 4: if n < 0, go to Step 7
                        Step 5: Print “n is Zero” and go to Step 8
                        Step 6: Print “n is a +ve number” and go to Step 8
                        Step 7: Print “n is a –ve number”
                        Step 8: Stop

3.    Write an algorithm to check whether a given number is even or odd.
Sol-                 Step 1: Start
                        Step 2: Read a number (n)
                        Step 3: if remainder of n/2 is = 0, go to Step 5 
                                     or if n % 2 = 0, go to Step 5
                        Step 4: Print “n is odd” and go to Step 6
                        Step 5: Print “n is even”
                        Step 6: Stop

4.    Write an algorithm to find a person’s eligibility for voting, based on his/her age.
Sol-                 Step 1: Start
                        Step 2: Read the age of a person (age)
                        Step 3: if age > 18, go to Step 5
                        Step 4: Print “Person is not eligible for voting” and 
                                     go to Step 6
                        Step 5: Print “Person is eligible for voting”
                        Step 6: Stop

C. On Iterational Patterns
1.    Write an algorithm to print a number (5) 10 times.
Sol-                 Step 1: Start
                        Step 2: Initialize Counter to 1 (Count =1)
                        Step 3: Print ‘5’
                        Step 4: Count = Count + 1
                        Step 5: if Count < = 10 go to Step 3
                        Step 6: Stop

2.    Write an algorithm to print all the odd numbers between 1 and 10.
Sol-                 Step 1: Start
                        Step 2: Initialize Counter to 1 (Count =1)
                        Step 3: Print ‘Count’
                        Step 4: Count = Count + 2
                        Step 5: if Count < = 10 go to Step 3
                        Step 6: Stop

3.    Write an algorithm to print all the even numbers between 1 and 10.
Sol-                 Step 1: Start
                        Step 2: Initialize Counter to 2 (Count =2)
                        Step 3: Print ‘Count’
                        Step 4: Count = Count + 2
                        Step 5: if Count < = 10 go to Step 3
                        Step 6: Stop

Tuesday, September 21, 2010

Life Cycle of a Software Project




Software:- It is a collection of computer programs and related data that provide the instructions telling a computer what to do.


Project:- It is a sequence of tasks planned from beginning to end bounded by time, resources and required results.
  • So, a software project is a collection of programs and related data that are done in a planned manner with bounded time, resources and end results.
A software development process is a structure imposed on the development of a software product. It is also called as software life cycle or a software process.




The following diagram shows the step-by-step procedure of Software Development -



This diagram is known as Software Development Life Cycle (SDLC)


Requirements phase: In this phase the required data about the project is collected and are categorized into different types of requirements.

Design phase: At this stage the crude design of the whole project is made ready.

Implementation phase: This stage is concerned with the actual coding phase. The coding can be done in any languages.

Verification phase: It is to verify that the implementation done in the previous stage meets all the requirements collected in the 1st phase.

Maintenance phase: This is where the end product is put into use. User is using the product and if any changes are needed that are to be incorporated at this stage.

  • All these phases may be repeated as many times as possible until the desired product is available.

PFC Syllabus

PROGRAMMING FUNDAMENTALS WITH C
(CS100 / CS150)

1)    Introduction: Logical Organization of Computer, Stored program concept. [1H]
2)    Programming Process: Life Cycle of a Software Project, Importance of adhering to Standards, Using Algorithms to Solve Problems, Different Patterns in Algorithms, Flow Charts. [4 H]
3)    Introduction to C Language: Structure of a C program with example, Character Set, C Tokens, Data types, Arithmetic operators, Expressions – Evaluation of an expression, Assignment statements – increment and decrement operators, compound assignment operators, Nested assignments, Simple Input and output, Type conversions, Simple Macros. [6 H]
4)  Selective Structure: Relational Operators, Logical operators, Bitwise Operators Conditional Statement, Nested conditional statement, Multi-way conditional statement, Constant Multi-way conditional Statement, (switch statement), break statement, go to statement, The ? operator. [4 H]
5)   Repetitive structure: While, do – while, for, nested loops, loop interruption – break and continue, null statement, comma operator. [4 H]
6)   Arrays: One Dimensional arrays- declaration and initialization, Two Dimensional arrays - declaration and initialization. Arrays as function arguments. [6 H]
7)   Functions: To understand the need to use functions, the advantages of functions, Function definition, function call, function prototypes, storage classes, Parameter passing techniques, arrays as function arguments. [5 H]
8)   Pointers and Strings: Introduction to pointers, how to declare pointers, how to access values through pointers, Pointer arithmetic, the relationship between arrays and pointers. Array of pointers, Command line arguments Declaration and initialization of strings, the memory representation of strings, pointers and strings, various string functions: strlen (), strcat(), strcpy(), strcmp(); parameter passing techniques. [12 H]
9)  Structures and Unions: Basics of structures, Structures and arrays, Basics of Unions. [6 H]

Books:
1)   Programming in ANSI C by E Balagrusamy, TMH third Edition
2)   The programming languages C by 
    Brian W. Kernighan & Dennis M. Ritchie, 2nd Edition PHI 2004
3)   How to solve it by computer by Dromey R. G, PHI 2001
 4) The Practice of Programming by 
     Brain W. Kernighan and Rob Pike, PEI 2004

Sunday, September 19, 2010

Logical Organization of a Computer and Stored Program Concept

LOGICAL ORGANIZATION OF A COMPUTER:

The following diagram shows the logical organization of a Computer-


This is also known as the von Neumann Architecture.


The von Neumann architecture is a design model for a stored-program digital computer that uses a central processing unit (CPU) and a single separate storage structure ("memory") to hold both instructions and data.

  • It is named after the mathematician and early computer scientist John von Neumann.



STORED PROGRAM CONCEPT:

A stored-program digital computer is one that keeps its programmed instructions, as well as its data, in read-write, random-access memory (RAM).

Stored-program computers were an advancement over the program-controlled computers of the 1940s, such as the Colossus and the ENIAC, which were programmed by setting switches and inserting patch leads to route data and to control signals between various functional units.

  • The terms von Neumann architecture and stored-program computer are generally used interchangeably.