Coefficient of Thermal Expansion and their Importance.pptx
CP Handout#1
1. C-Programming
Walchand Institute of Technology (RC1131), Solapur Page 1
Handout#1
Assignment/Program Statement:
Introduction to Computer and Study of basics of programming such as algorithm
and flowchart.
Learning Objectives:
Students will be able to
- explain computer parts,
- write an algorithm
- draw flowchart
Theory:
Computer:
Computer is an advanced electronic device that takes raw data as input from the
user and processes it under the control of set of instructions (called program), gives
the result (output), and saves it for the future use.
Block Diagram of Computer and Various Components of Computer:
Computer is a device that transforms data into meaningful information.
Data can be anything like marks obtained by you in various subjects.
It can also be name, age, sex, weight, height, etc. of all the students in a
class.
Computer can also be defined in terms of functions it can perform.
A computer can i) accept data, ii) store data, iii) process data as desired,
and iv) retrieve the stored data as and when required and v) print the
result in desired format.
The major characteristics of a computer are high speed, accuracy,
diligence, versatility and storage.
A computer as shown in figure performs basically five major computer
operations or functions irrespective of their size and make. These are:
1) It accepts data or instructions by way of input,
2) It stores data (STORAGE UNIT),
3) It can process data as required by the user (ALU),
2. C-Programming
Walchand Institute of Technology (RC1131), Solapur Page 2
4) It gives results in the form of output (OUTPUT UNIT), and
5) It controls all operations inside a computer (CONTROL UNIT).
1. Input:
This is the process of entering data and programs in to the computer system.
Computer takes as inputs raw data and performs some processing giving out
processed data.
Therefore, the input unit takes data from us to the computer in an organized
manner for processing.
2. Storage:
The process of saving data and instructions permanently is known as
storage.
Data has to be fed into the system before the actual processing starts. It is
because the processing speed of Central Processing Unit (CPU) is so fast
that the data has to be provided to CPU with the same speed.
Therefore the data is first stored in the storage unit for faster access and
processing. This storage unit provides space for storing data and
instructions.
The storage unit performs the following major functions:
- All data and instructions are stored here before and after processing.
- Intermediate results of processing are also stored here.
INPUT
UNIT
STORAGE
UNIT
OUTPUT
UNIT
CONTROL
UNIT
ARITHMETIC
LOGIC UNIT
PROGRAM
& DATA
RESULTS
CENTRAL
PROCESSING
UNIT
(CPU)
Figure: Basic Computer Operations
3. C-Programming
Walchand Institute of Technology (RC1131), Solapur Page 3
3. Processing:
The task of performing operations like arithmetic and logical operations is
called processing.
The Central Processing Unit (CPU) takes data and instructions from the
storage unit and makes all sorts of calculations based on the instructions
given and the type of data provided. It is then sent back to the storage unit.
4. Output:
This is the process of producing results from the data for getting useful
information.
Similarly the output produced by the computer after processing must also be
kept somewhere inside the computer before being given to you in human
readable form.
Therefore, the output is also stored inside the computer for further
processing.
5. Control:
The manner how instructions are executed and the above operations are
performed.
Controlling of all operations like input, processing and output are performed
by control unit.
It takes care of step by step processing of all operations inside the computer.
[Reference:http://ecomputernotes.com/fundamental/introduction-to-computer/draw-the-block-
diagram-of-computer-and-explain-its-various-components ]
Algorithm:
An algorithm is a well-defined procedure that allows a computer to solve a
problem.
OR
An algorithm is a sequence of unambiguous instructions.
OR
An algorithm is an ordered sequence of instructions for solving a problem.
OR
4. C-Programming
Walchand Institute of Technology (RC1131), Solapur Page 4
An algorithm is any well-defined computational procedure that takes some
value, or set of values, as input and produces some value, or set of values, as
output. An algorithm is thus a sequence of computational steps that transform the
input into the output.
[Reference: http://algoviz.org/OpenDSA/Books/CS3114/html/AnalPrelim.html# ]
Ex.1 Suppose we want to calculate addition of two numbers then algorithm could
be,
Algorithm: Addition of two numbers.
Step1: Read two numbers a & b.
Step2: Calculate addition c=(a+b).
Step3: Print addition i.e. print c.
Step4: Stop
Ex.2 Write an algorithm to read two numbers and print the bigger.
Algorithm: Bigger of two numbers.
Step1: Read a & b
Step2: if a>b
print a
goto step3
else
print b.
goto step3
Step3: Stop
Ex.3 Write an algorithm to print 1 to 10 numbers.
Algorithm: Print 1 to 10 numbers.
Step1: Start
Step2: i=1
Step3: if i<=10
print i
i=i+1
go to step3
else
5. C-Programming
Walchand Institute of Technology (RC1131), Solapur Page 5
go to step4
Step4: Stop.
Flowchart:
The flowchart is a diagrammatic/graphical/pictorial representation of the
algorithm.
OR
An algorithm can be written as a list of steps using text, or as a picture called a
flowchart.
Elements of a Flowchart:
Various geometrical shaped boxes represent the steps of the solution.
The boxes are connected by directional arrows to show the flow of the
solution.
Flowchart Symbols: In a flowchart each type of symbol has a specific meaning.
Some flowchart symbols are given below:
Symbol Name Meaning
Terminal Start and Stop Box
Parallelogram Input and Output Box
Rectangle Process Box
Rhombus Decision Making Box
6. C-Programming
Walchand Institute of Technology (RC1131), Solapur Page 6
Circle Continuation Box
Arrows Flow Arrows
Hexagon Repetition/Looping
Guidelines to draw a flowchart:
Identify input and output.
Apply reasoning skills to solve the problem.
Draw the flowchart using the appropriate symbols and arrows to show the
sequence of steps in solving the problem.
7. C-Programming
Walchand Institute of Technology (RC1131), Solapur Page 7
Ex.1 Draw flowchart for calculating Ex.2 Draw flowchart for calculating
addition of two numbers. average of three numbers.
Uses of Flowchart:
Flowcharts are useful to study the problem because diagrammatic
representation can be easily understood by human beings.
To specify the method of solving a problem.
To plan the sequence of a computer program.
Communicate ideas, solutions.
Ex.3 Draw flowchart to read two numbers and print the bigger.
8. C-Programming
Walchand Institute of Technology (RC1131), Solapur Page 8
Ex.4 Draw flowchart to print 1 to 10 numbers.
[Reference: http://cprogrammingcodes.blogspot.in/2011/09/algorithms-and-flowchart.html ]
9. C-Programming
Walchand Institute of Technology (RC1131), Solapur Page 9
Practice Problem Statements:
1) Write an algorithm to calculate average of 3 numbers.
2) Write an algorithm to read mark of the subject and print the result. Given
that a candidate must score at least 40 marks to pass the subject.
3) Draw flowchart to read mark of the subject and print the result. Given that a
candidate must score at least 40 marks to pass the subject.
4) Draw a flow chart to display 1 to 50 numbers.
Conclusion:
Thus we studied
- Basic blocks of computer
- Algorithm
- Flowchart
Learning Objectives:
At the end of this assignment, students are able to
- explain computer parts,
- write an algorithm
- draw flowchart