Write an algorithm and draw a corresponding flowchart to print the sum of all integers starting from 2 to the given positive integer x where x >= 2. 10m Dec2006
An algorithm is a finite set of steps defining the solution of a particular problem. An algorithm is expressed in pseudo code – something resembling C language or Pascal, but with some statements in English rather than within the programming language
- A sequential solution of any program that written in human language, called algorithm.
- Algorithm is first step of the solution process, after the analysis of problem, programmers write the algorithm of that problem.
- Initialize I to zero , Sum to zero
- Input a Number
- While I is Less than equal to Number
- If SNUM equal to ‘2’
- Increment I
- Print SUM
Step 1: Input NUM
Step 2: I = 0 , SUM =0
Step 3: While ( I<= NUM)
If ( SSNUM == ‘2’)[I] == S[J] )
Step 6: Print SUM
Step 7: End