Docsity

Lab Exercise: Algorithms & Flowcharts for Sequence & Selection Control Structures, Lab Reports of Physics

Toggle sidebar
bg1
LABORATORY EXERCISE NO. 3: SEQUENCE AND SELECTION CONTROL STRUCTURES
Practice.
1. Design an algorithm and flowchart to read height in centimeters and convert to feet and
inches.
Algorithm
Flowchart
-Start
-Read height (H) in centimeters
-Compute height in Feet (Ft) as
Ft= H/30.48cm
-Compute height in Inches (In) as
In= H/2.54cm
-Write (Display) height in Ft and In
-Stop
Start
Read height
Ft = H /30.48cm
In = H/2.54cm
Write height in Ft and In
Stop
pf3
pf4
pf5

Partial preview of the text

Download Lab Exercise: Algorithms & Flowcharts for Sequence & Selection Control Structures and more Lab Reports Physics in PDF only on Docsity!

LABORATORY EXERCISE NO. 3: SEQUENCE AND SELECTION CONTROL STRUCTURES

Practice.

  1. Design an algorithm and flowchart to read height in centimeters and convert to feet and inches. Algorithm Flowchart
  • Start
  • Read height (H) in centimeters
  • Compute height in Feet (Ft) as Ft= H/30.48cm
  • Compute height in Inches (In) as In= H/2.54cm
  • Write (Display) height in Ft and In
  • Stop Start Read height Ft = H /30.48cm In = H/2.54cm Write height in Ft and In
  1. Design an algorithm and flowchart to swap two numbers using temporary variable. Algorithm Flowchart
  • Start
  • Read NUM1 and NUM
  • Set Temporary Number as TEMP=NUM
  • Set NUM1 as NUM1=NUM
  • Set NUM2 as NUM2=TEMP
  • Write (Display) NUM1 and NUM 2
  • Stop Start Read NUM1 and NUM TEMP = NUM NUM1 = NUM NUM2 = TEMP Write NUM1 and NUM
  1. Design an algorithm and flowchart to check whether the input year is a leap year or not. Algorithm Flowchart
  • Start
  • Read Year (A)
  • If input year (A) is divisible by 4 Write (Display) Leap Year
  • Else Write Not
  • Stop Start Read A True (^) False A is divisible by 4? Write Leap Year Write^ Not
  1. Design an algorithm and flowchart to evaluate the input grade or scores if its grade A, B,C, D, or E. A: 95 – 100 B: 90 – 94 C: 80 – 89 D: 70 – 79 E: 69 and below Algorithm Flowchart
  • Start
  • Read Input Grades
  • If input grades is less than or equal to 69 Write E
  • End if
  • If input grades is greater than 69 and less than 80 Write D
  • End if
  • If input grades is greater than 79 and less than 90 Write C
  • End if
  • If input grades is greater than 89 and less than 96 Write B
  • End if
  • If input grades is greater than 94 and less than 100 Write A
  • End If
  • Stop