Tuesday, February 1, 2011

Computer Programming Unit I (JNTU I YEAR)








INTRODUCTION TO COMPUTERS

a)      Computer  System .

b)      Computing Environments .

c)      Computer Languages .

d)      Creating and Running Programs .

e)      Software Development Method .

f)       Algorithms .

g)      Pseudo Code .

h)      Flowchart .

i)        Applying The Software Development Method .





 Computer System

Definition : A Computer is an electronic computing device performs operations like accepting the data , storing the data , manipulate or computing the data and produce the desired output .

Basic Hardware Components of a computer are :
·         Input Devices .
·         Output Devices .
·         System Units
·         CPU (Central Processing Unit .
·         Memory .
·         Storage Devices .
Input Devices : - These device allows the user to enter the information in the form of data and commands into the memory of the computer .  Ex : Keyboard , Mouse
Output Devices : - These devices display the information generated by the processor in the form of Human understandable langauage . Ex : Monitor , Printer .
System Units : - This unit consists of a Circuit Board called Mother Board , Which has two main components like CPU and Memory unit .
Storage Devices :- These are the devices which store the information . Ex : floppy disks , Hard disks , CD ,DVD’s .
Types of Computers can be classified to three types :
·         Data Handing Computers
·         Digital Computers
·         Analog Computers
·         Hybrid Comuters .
·         Individual Computers .
·         Desktop Computers .
·         Workstations .
·         Laptops .
·         Tablet Computers .
·         PDA’s .
·         Smart Phones .
·         Organization Computers .
·         Network Servers .
·         Mini Computers .
·         MainFrames .
·         Super Computers .




Software :- Is a Set of instructions given to a computer to perform a certain task . Both software and Hardware are necessary for doing any job using a computer . Software without computer is useless . Software  can be classified to two they are
·         System Software
·         Operating System , Compilers , Assemblers .
·         Application Software
·         Payroll Software , Hospital Billing Software   etc.,

Applications of a  Computer :
Computer are widely used in many areas
·         Science.
·         Education.
·         Medicine and Health .
·         Engineering .
·         Architecture .
·         Manufacturing .
·         Entertainment .
·         Communication .
·         Business and Banking
·         Government .

Characteristics of Computer :
·         Speed : The Speed of computer can be measured in MIPS ( Millions of instructions per second ) because it cam perform millions of operations in one second .
·         Accuracy  : Computers do not make mistakes in calculations they produce output very accurately .
·         Reliability : It gives correct and consistent results always even if they are used in adverse conditions .
·         Storage capability : Computers store large amount od information .
·         Versatility : Computers can do variety of tasks based on the instructions given to them .
·         Diligence : Computers can perform complicated work without any break for days together .

Computing environments
 There qre four Computing Environments
·         Personal Computing Environment .
·         Time – Sharing Environment .
·         Client / Server Environment .
·         Distributed Computing Environment .



·         Personal Computing Environment : These computer are specially designed for the normal personal use of the computer users .
·         Time – sharing Environment : There will be a central computer where it will assing specific duties to all its connected computers and pheriperals like fax,printers etc.,
·         Client / Server Environment : The users computer is called Client and the Central computer which controls the client is called Server .
·         Distributed computing  Environment : A distributed computing provides a seamless integration of computing functions betwen servers and clients .

Computer languages
Computer Languages are the platforms to develop the programs . These are classified to two
v  Low Level Langauge.
v  High Level Language.

Low Level Language :
Low Level Language is further classified to
·         Machine / Binary Level Langaueg.
·         Assembly / Symbolic Language

Machine  / Binary  Level Language : This is a First generation Programming Language , which contains only binary digits like 1 and 0. Where Binary number 0 represents Low Voltage  and 1 represent High Voltage .This language uses some of the operational codes(Op Code)  like

Op Code
Meaning
0001
Addition
0010
Substraction
0011
Multiplication
0100
Division
Advantages :
Computer can understand binary langauge .

DisAdvantages :
-       It is Machine independent .
-       Very difficult to remember op codes .
-       Debugging and modifiying the program  is very dificult .

Assembly / Symbolic Language : To avoid the disadvantages of Machine langauge Assembly langauge is introduced in the year 1950 . This is a second generation language , which contain Symbolic codes called  “Mnemonics”( Memory Shakes)  . This language uses some of the Mnemonic codes like

Mnemonic  Code
Meaning
ADD
Addition
SUB
Substraction
MULT
Multiplication
DIV
Division
Advantages :
-       Users can easily remember Mnemonic codes .
-       User can Debug and modify code easily.
-       Suitable to develop simple application .

Disadvantages :
-       It  is alos Machine independent .
-       It needs a translator program like assembler .


High Level Language :
These Langauges are developed to overcome the disadvantages of Low Level Langauges . These are English like Langauges .These are classified to two
·         General Purpose Languages .
·         Basic , Pascal , C   etc.,
·         Specific Purpose Langauges .
·         Cobol , Fortran , C++ , Prolog , Java   etc.,

Advantages :
-       Easy to follow.
-       Easy to write , modify and Debug the code .
-       Can create difficult applications .

Disadvantages :
-       Need a translator like Compiler or a intrepreters .
-       Less efficient than Low Level Languages .

Creating and running program :
Creating and running a program has four steps
·         Writing /  Modifying the code
·         Compiling the code .
·          Linking the code .
·         Executing the code



This is the flow chart representation of  creating and running a Program .
Program development method :
The following steps are used in sequence for developing an efficient program
·         Specification .
·         Designing an algorithm
·         Coding / Implementation .
·         Debugging .
·         Testing and validation .
·         Documantation .

Specification :
 Working with existing system and using proper questionnaire, the problem should be explained clearly.
 What inputs are available, outputs are required and what is needed for creating workable solution should be understood clearly in this step .The method of solutions to solve the problem can be identified. We also judge that which method gives best results among different methods of solution.

Designign an Algorithm :
Algorithms and flow charts will be prepared. Keep focus on data, architecture, user interfaces and program components.

Coding / Implementation :
The algorithms and flow charts developed in the previous steps are converted into actual programs in the high level languages like C. 

Debugging :
Translate the program into machine code. This process is called as Compilation. And the process of finding errors is called Debugging .Syntactic errors are found quickly at the time of compiling the program. These errors occur due to the usage of wrong syntaxes for the statements.
                    Eg:  x=a*y+b
There is a syntax error in this statement, since, each and every statement in C language ends with a semicolon (;).
The next step is Program execution. In this phase, we may encounter two types of errors.
Runtime Errors: these errors occur during the execution of the program and terminates the program abnormally.
Logical Errors: these errors occur due to incorrect usage of the instructions in the program. These errors are neither detected during compilation or execution nor cause any stoppage to the program execution but produces incorrect ouz

Testing and Validation :
This step is performed to check whether the program is producing correct results or not for different values of input .
Documentation and maintenance :
Documentation is the process of collecting , organizing and maintaining the complete information of the program for furthur use . Maintenance is the process of upgrading the program according to the changing requirements .

Algorithm / pseudo code :
The Step-by-Step representation of a problem or program is know as Algorithm . It should be written in English like sentences and can also be called as Pseudo Code . some of the important properties of an algorithm are
·         Finiteness : An algorithm must terminate in finite number of steps
·         Definiteness : Each step of the algorithm must be precisely and unambiguously stated .
·         Effectiveness : Each step should be executed in a finite amount of time .
·         Generality : The algorithm shoule be complete and specific to accept any input data .
·         Input / Ouput : Each algorithm must take zero, one or more inputs and produce one or more output values .

Flowchart :
Flowchart is a diagrammatic representation of an algorithm .It use many symbols and arrows to represent an algorithm as show in the table below .
 

Q1) Write an Algorithm and draw flowchart for finding the biggest among three given numbers .
Ans :   a) Algorithm  :
           
            Step 1 : Start .
            Step 2:: Read Three Values
            Step 3 : Compare X and Y.
            Step 4 : Otherwise Compare Y and Z .
            Step 5 : Compare X and Z .
            Step 6:  Terminate

            b) Flowchart :
 
Q2) Write an Algorithm and draw flowchart for finding the given number is Even or Odd. .
Ans :   a) Algorithm :
Step1: Begin
Step2: Take a number
Step3: if the number is divisible by2 then
            print that number is even
             otherwise print that number is odd
Step4: End


            b) Flowchart :

 
Q3) Write an Algorithm and draw flowchart for swapping given two numbers.
Ans :     a) Algorithm :
            Step 1: Start.
            Step 2: Read  two numbers
            Step 3:. Exchange X and Y
            Step 4: Output the result
            Step 5: Stop / Terminate .

            b) Flowchart :







1 comment:

  1. thanks . because of you we can refer all the required documents. thanks a lot.

    ReplyDelete