This document discusses different programming techniques including straight line constructs, conditional/selection constructs, and iteration/loop constructs. Straight line constructs involve executing a series of steps sequentially without branching. Conditional/selection constructs allow certain instructions to execute depending on input conditions being true or false. Iteration/loop constructs allow steps to repeat until a condition is met. Examples are provided for algorithms using each type of construct.
This document discusses different programming techniques including straight line constructs, conditional/selection constructs, and iteration/loop constructs. Straight line constructs involve executing a series of steps sequentially without branching. Conditional/selection constructs allow certain instructions to execute depending on input conditions being true or false. Iteration/loop constructs allow steps to repeat until a condition is met. Examples are provided for algorithms using each type of construct.
Copyright:
Attribution Non-Commercial (BY-NC)
Available Formats
Download as ODT, PDF, TXT or read online from Scribd
This document discusses different programming techniques including straight line constructs, conditional/selection constructs, and iteration/loop constructs. Straight line constructs involve executing a series of steps sequentially without branching. Conditional/selection constructs allow certain instructions to execute depending on input conditions being true or false. Iteration/loop constructs allow steps to repeat until a condition is met. Examples are provided for algorithms using each type of construct.
Copyright:
Attribution Non-Commercial (BY-NC)
Available Formats
Download as ODT, PDF, TXT or read online from Scribd
A program can have one or more of the different techniques discussed below:
1. Straight line construct
2. Conditional and selection construct 3. Iteration or loop construct Straight line construct Straight line program sometimes called sequential progam or serial construct.The serial construct consist of one operation executed after another in a series. Example: Write an algorithm to find the area of a circle when radius is given. Algorithm: Step-1 :Read the radius of the circle as r. Step-2 :Set area=0. Step-3 :Calculate area=2*3.141*r*r Step-4 :Print the area Step-5 :End P-1. Write an algorithm to convert Dollar($) into Rupee. P-2. Write an algorithm to convert centigrade to farenhite. P-3. Write an algorithm to enter the marks in 3 subject and find out the total mark and percentage of mark assuming full mark in each subject is 100. Conditional and selection construct Sometimes ,instead of executing all the instruction, only suitable instructions are executed depending on the inputs and the condition involved. In conditional branching it relaies upon testing a condition which results is either True or False. Example. Write an algorithm to find the greatest among two given numbers. Algorithm Step-1 :Take two numbers as num1 and num2. Step-2 : if (num1>num2) Print num1 is greatest. Else Print num2 is greatest. End if Step-3:End P-4. Write an algorithm to check wheather a person is elligible to give vote or not when the age is inputed. P-5. Write an algorithm to find greatest among three given numbers. P-6. Write an algorithm to find out the grade of a student in an examination when percentage is given. Marks<40 grade is 'D”.Mark between 40 to 49 grade 'C',Mark between 50 to 59 grade 'B'.Mark >=60 grade 'A'.