Unit-1 C
Unit-1 C
Unit-1 C
Introduction to Programming
Unambiguous − Algorithm should be clear and unambiguous. Each of its steps (or
phases), and their inputs/outputs should be clear and must lead to only one
meaning.
Input − An algorithm should have 0 or more well-defined inputs.
Output − An algorithm should have 1 or more well-defined outputs, and should
match the desired output.
Finiteness − Algorithms must terminate after a finite number of steps.
Feasibility − Should be feasible with the available resources.
Independent − An algorithm should have step-by-step directions, which should be
independent of any programming code.
Algorithm
Design an algorithm to add two numbers and display the result.
Step 1 − START
Step 2 − declare three integers a, b & c
Step 3 − define values of a & b
Step 4 − add values of a & b
Step 5 − store output of step 4 to c
Step 6 − print c
Step 7 − STOP
Algorithm
Algorithm Questions
1) Find the sum of first five integers and its Average.
2) Convert a given temp in F to C (c=5/9 *(F-32))
3) To find the area of the right angle triangle
4) To find Simple Interest when principal, rate of interest and
Time given
5) To check whether a number is prime or not
6) To find roots of quadratic equation
7) Print the sum for first 50 natural numbers
8) Print factorial of number.
9) Write an algorithm to evaluate
51+52+… +510
Efficiency of Algorithm
Space complexity of an algorithm represents the amount of
memory space required by the algorithm in its life cycle.