You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Jul 13, 2025. It is now read-only.
@@ -314,53 +314,75 @@ The main goal of structured programming is to improve code readability, maintain
314
314
# Chapter-09
315
315
## Algorithms
316
316
317
-
According to the computer scientist Niklaus Wirth stated that- PROGRAM = ALGORITHMS + DATA
317
+
* According to the computer scientist *Niklaus Wirth* stated that- **PROGRAM = ALGORITHMS + DATA**
318
+
318
319
An algorithm is a part of the plan for the computer program and an effective procedure for solving a problem in a finite number of steps. Algorithm may be represented in various ways. These are four ways of stating algorithms-
319
-
• Step-form: The procedure of solving a problem is stated with written statements. Each statement solves a part of the problem and these together complete the solution. The step-form uses normal language to define each procedure.
320
-
• Pseudo-code: The pseudo-code is a written form representation of the algorithm but it differs from the step-form as it uses a restricted vocabulary to define its action of solving the problem.
321
-
• Flowchart & Nassi-Schneiderman: These two are graphically oriented representation forms. They use symbols and language to represent sequence, decision and repetition actions.
320
+
321
+
1.**Step-form:** The procedure of solving a problem is stated with written statements. Each statement solves a part of the problem and these together complete the solution. The step-form uses normal language to define each procedure.
322
+
323
+
2.**Pseudo-code:** The pseudo-code is a written form representation of the algorithm but it differs from the step-form as it uses a restricted vocabulary to define its action of solving the problem.
324
+
325
+
3.**Flowchart & Nassi-Schneiderman:** These two are graphically oriented representation forms. They use symbols and language to represent sequence, decision and repetition actions.
322
326
Algorithms show these three features:
323
-
1. Sequence (also known as process): Sequence means that each step or process in the algorithm is executed in the specific order.
324
-
2. Decision (also known as selection): (if…. then, if…. then…. else…) In algorithms the outcome of a decision is either true or false; there is no state in between.
325
-
If proposition
326
-
then process1
327
-
else process2
328
-
This is the if… then… else… form of the decision. This means that if the preposition is true then execute process1, else, or otherwise, execute process2.
329
-
3. Repetition (also known as iteration or looping): repeat and while. repeat loop, while loop, if… then go to ... loop. The repeat loop is used to iterate or repeat a process or sequence of processes until some condition becomes true. It has the general form:
330
-
Syntax: Example:
331
-
Repeat Repeat
332
-
Process1 Fill water in kettle
333
-
Process2 until kettle is full
334
-
……….……
335
-
ProcessN
336
-
Until proposition
337
-
338
-
While preposition while kettle is not full
339
-
Begin fill water in kettle
340
-
Process1
341
-
Process2
342
-
……………
343
-
ProcessN
344
-
end
345
-
346
-
If … then goto … is:
347
-
Process1 Fill some water in kettle
348
-
Process2 if kettle not full then goto 1
349
-
……………
350
-
ProcessN
351
-
If proposition then goto Process1
352
-
353
-
Constant and Variable: Constant is a fixed value that can’t be changed. On the other hand, the variable is a container for a value that may vary during the execution of the program. For example, in the tea-making algorithm, the cup and kettle are constant whether the water level, water temperature and quantity of tea leaves are variable.
327
+
328
+
1.**Sequence (also known as process):** Sequence means that each step or process in the algorithm is executed in the specific order.
329
+
330
+
2.**Decision (also known as selection):** (if…. then, if…. then…. else…) In algorithms the outcome of a decision is either true or false; there is no state in between.
331
+
332
+
If proposition
333
+
then process1
334
+
else process2
335
+
336
+
This is the if… then… else… form of the decision. This means that if the preposition is true then execute process1, else, or otherwise, execute process2.
337
+
338
+
3. **Repetition (also known as iteration or looping):** repeat and while. repeat loop, while loop, if… then go to ... loop. The repeat loop is used to iterate or repeat a process or sequence of processes until some condition becomes true. It has the general form:
339
+
*Syntax:*
340
+
341
+
Process1 Fill water in kettle
342
+
Process2 until kettle is full
343
+
ProcessN
344
+
Until proposition
345
+
While preposition while kettle is not full
346
+
347
+
Begin
348
+
fill water in kettle
349
+
Process1
350
+
Process2
351
+
……………
352
+
ProcessN
353
+
end
354
+
355
+
If … then goto … is:
356
+
Process1 Fill some water in kettle
357
+
Process2 if kettle not full then goto 1
358
+
……………
359
+
ProcessN
360
+
If proposition then goto Process1
361
+
362
+
**Constant and Variable:** Constant is a fixed value that can’t be changed. On the other hand, the variable is a container for a value that may vary during the execution of the program. For example, in the tea-making algorithm, the cup and kettle are constant whether the water level, water temperature and quantity of tea leaves are variable.
363
+
354
364
Developing algorithms using step-form:
365
+
355
366
1. START and STOP
356
367
2. INPUT or READ
357
368
3. PRINT
358
369
4. Operators-
359
-
a. Arithmetic Operators: ←; The expression X←6 means that a value 6 is assigned to the variable X. Examples: +, -, *, /, %
360
-
b. Relational Operators
370
+
a. Arithmetic Operators: ←; The expression X←6 means that a value 6 is assigned to the variable X. Examples: +, -, *, /, %
371
+
b. Relational Operators
361
372
362
373
# Chapter-10
363
374
## Algorithms and Flowcharts
375
+
376
+
### Algorithms
377
+
In mathematics and computer science, an algorithm is a finite sequence of rigorous instructions, typically used to solve a class of specific problems or to perform a computation. Algorithms are used as specifications for performing calculations and data processing1.
378
+
### Flowcharts
379
+
380
+
* A flowchart is a graph used to depict or show a step by step solution using symbols which represent tasks.
381
+
* The symbols used consist of geometrical shapes that are connected by flow lines.
382
+
* It is an alternative to using pseudocode; while a pseudocode description is verbal, a flowchart is graphical in nature.
0 commit comments