Computer Science Questions From Chapter 10 For Class 10 11
Computer Science Questions From Chapter 10 For Class 10 11
Date: 12-Nov-2016
Class: 10 & 11
Subject: Computer Science
Teacher: Lubna Tanweer
Q1: Show two ways of selecting different actions using Pseudocode.
Ans:
If Condition
Begin
Input grade
If grade >= 60
End
Case Statement
Begin
Input grade
CASE grade OF
‘A’ : points = 4
‘B’ : points = 3
‘C’ : points = 2
‘D’ : points = 1
‘F’ : points = 0
ENDCASE
Output points
End
Q2: You have been asked to choose the correct routine from the menu shown below.
a) Decide which type of conditional statement are you going to you use.
b) Explain your choice.
c) Write the Pseudocode
d) Select your test data and explain why you choose each value.
Answer:
Begin
Input Choice
Case Choice of
1 : SetUpNewAccount;
2 : MakeChangesToAnExistingAccount;
3: CloseAnAccount;
4 : ViewMyOrders;
5 : PlaceANewOrder;
6 : AlterAnExistingOrder;
0 : Exit;
H : Help;
End Case
End
Q3: Show three ways to use a loop to add up five numbers and print out the total can be set up using
Pseudocode. Explain which loop is the most efficient to use.
Answer:
There are three different loop structures that we can use to add five numbers.
Begin
Sum=0
For Count = 1 to 5
Input Num
Next Count
End
Begin
Sum=0
Count = 0
Repeat
Input Num
Count = Count + 1
Until Count = 5
End
Begin
Sum=0
Count = 0
While Count<5 Do
Input Num
Count = Count + 1
EndWhile
Output “Total = ”, Sum
End
Q4: A sweets shop sells five hundred different types of sweets. Each sort of sweet is identified by a
different four digit code. All sweets that start with 1 are Chocolates, All sweets that start with 2 are
toffees, All sweets that start with 3 are jellies and all other sweets are miscellaneous and can start with
any other digit except zero.
a) Write an algorithm, using a flowchart or Pseudocode which input the four digit code for all 500
items and output the number of chocolates, toffees and jellies.
b) Explain how you would test your flow chart.
c) Decide the test data to use and complete a trace table showing a dry run of your flow chart.
Answer:
Begin
TotalChocolate = 0
TotalToffees = 0
TotalJellies = 0
For Count = 1 to 500
Input Code
If Code >= 1000 And Code <=1999
Then TotalChocolate = TotalChocolate + 1
Else
If Code >= 2000 And Code <=2999
Then TotalToffees = TotalToffees + 1
Else
If Code >= 3000 And Code <=3999
Then TotalJellies = TotalJellies + 1
End If
End If
End If
Next Count
Output “Total Number Of Chocolates :” , TotalChocolate
Output “Total Number Of Chocolates :” , TotalToffees
Output “Total Number Of Jellies :” , TotalJellies
End
Q5: The temperature in an apartment must be kept between 18⁰C and 20⁰C. If the temperature
reaches 22⁰C then the fan is switched On; If the temperature reaches 16⁰C then the heater is
switched On; otherwise the fan and the heater are switched Off. The following library routines
are available:
GetTemperature
FanOn
FanOff
HeaterOn
HeaterOff
Write an algorithm using Pseudocode or flow chart, to keep the temperature at the right level.
Begin
Input Temperature
If Temperature >= 22
Then FanOn;
Else
If Temperature <= 16
Then HeaterOn;
Else
FanOff;
HeaterOff;
End If
End If
End
Q6: Daniel lives in Italy and travels to Mexico, India and New Zealand. The time difference are:
Begin
OneDigit = 0
TwoDigit = 0
ThreeDigit = 0
FourDigit = 0
OutSide = 0
For Count = 1 to 500
Input Number
If Number >= 0 And Number <=9
Then OneDigit = OneDigit + 1
Else
If Number >= 10 And Number <=99
Then TwoDigit = TwoDigit + 1
Else
If Number >= 100 And Number <=999
Then ThreeDigit = ThreeDigit + 1
Else
If Number >= 1000 And Number <=9999
Then FourDigit = FourDigit + 1
Else
OutSide = OutSide + 1
End If
End If
End If
End If
Next Count
Percentage = OutSide / 5000 * 100
Output “Total Number Of One Digit Numbers :” , OneDigit
Output “Total Number Of Two Digit Numbers :” , TwoDigit
Output “Total Number Of Three Digit Numbers :” , ThreeDigit
Output “Total Number Of Four Digit Numbers :” , FourDigit
Output “Percentage of numbers outside the range” , Percentage
End