Search This Blog

Thursday 14 October 2021

UNIT 01: PROBLEM SOLVING AND ALGORTHM DESIGNING - Lab Activities - Computer Science For Class X

GO TO INDEX

Computer Science For Class X
Unit 01: Problem Solving And Algorithm Designing
LAB ACTIVITIES


1. Design an algorithm to find the greater number by taking two numbers as input.
Ans: Greater Number By Taking two numbers
  • Step 1: Start
  • Step 2: Declare variable num1 , num2 & result
  • Step 3: Read num1 and num2
  • Step 4: Check If numl>num2 then print "Result = Number 1 is greater"
    Else print "Result = Number 2 is greater"
  • Step 5: Stop

OR

  • Step 1: Start
  • Step 2: Read a, b
  • Step 3: If a > b then
    Display “A is the largest number”,
    otherwise
    Display “B is the largest number”,
  • Step 4: Stop.

2) Design an algorithm to find area of a triangle.
Ans: Area Of A Triangle
  • Step 1: Start
  • Step 2: Declare variable Base, Height & Area of triangle
  • Step 3: Read Base and Height
  • Step 4: Use formula Area of triangle = (1/2)*Base*Height
  • Step 5 : Display Area of triangle
  • Step 6: Stop

OR

  • Step 1: Start
  • Step 2: Input base, height
  • Step 3: Calculate area =  ½ * base * height
  • Step 4: Display “Area of Triangle =“ area
  • Step 5: Stop

3. Sort the following steps of the algorithm in correct order for baking a cake:
Step: Gather the ingredients
Step: End
Step: Grease a pan
Step: Preheat the oven
Step: Put the pan in the oven
Step: Start
Step: Pour the batter into the pan
Step: When the timer goes off, take the pan out of the oven
Step: Set a timer
Step: Mix together the ingredients to make the batter

Ans: Baking A Cake
  • Step l: Start
  • Step 2: Gather the ingredients
  • Step 3: Mix together the ingredients to make the batter
  • Step 4: Grease a pan
  • Step 5: Pour the batter into the pan
  • Step 6: Preheat the oven
  • Step 7: Put the pan in the oven
  • Step 8: Set a timer
  • Step 9: When the timer goes off, take the pan out of the oven
  • Step 10: End

4. Draw a flow chart to calculate gross salary by adding 20% house rent and 30% medical allowances in basic salary.
Ans: Gross Salary Flowchart


OR



5. Draw a flow charts for all the algorithms given in this unit.
Ans:
Algorithm 1: Making a cup of tea
  • Step 1: Start
  • Step 2: Place the fresh water in a pot or a kettle.
  • Step 3: Boil the water.
  • Step 4: Put the black tea leaves in that pot.
  • Step 5: After that add some milk into that pot.
  • Step 6: Add some sugar.
  • Step 7: Boil for some time.
  • Step 8: Stop

Flowchart 1: Making a cup of tea

Algorithm 2: Sum of two numbers
  • Step 1: Start
  • Step 2: Declare variables num1, num2 and sum.
  • Step 3: Read values num1 and num2.
  • Step 4: Add num1 and num2 and assign the result to sum.
    sum = num1 + num2
  • Step 5: Display sum
  • Step 6: Stop

Flowchart 2: Sum of two numbers

OR



Algorithm 3: Average of three numbers
  • Step 1: Start
  • Step 2: Declare variables num1, num2, num3 and avg.
  • Step 3: Read values num1, num2 and num3.
  • Step 4: Apply formula {Average = Sum / No. of values}
    avg = (num1 + num2 + num3) / 3
  • Step 5: Display avg
  • Step 6: Stop
Flowchart 3: Average of three numbers


OR



Algorithm 4: Volume of a box
  • Step 1: Start
  • Step 2: Declare variables length, width, height and volume.
  • Step 3: Read values length, width and height.
  • Step 4: Apply formula {Volume = length x width x height}
    volume = length x width x height
  • Step 5: Display volume
  • Step 6: Stop

Flowchart 4: Volume of a box

OR



Algorithm 5: Percent Calculate
  • Step 1: Start
  • Step 2: Declare variables part, total and percentage.
  • Step 3: Read values part and total.
  • Step 4: Apply formula {Percentage = (part / total) x 100}
    percentage = (part / total) x 100
  • Step 5: Display percentage
  • Step 6: Stop

Flowchart 5: Percent Calculate

OR



6. Draw the following structure
a. Tree with six nodes.
b. Graph with five nodes.

Ans: TREE WITH SIX NODES:


OR



GRAPH WITH FIVE NODES


OR





No comments:

Post a Comment