
- •Royal International Language School
- •Computer Revision Sheet (Prep.3) Second Term
- •Dim u_Name As String
- •Dim w , l As Single
- •Because Enter (String value)
- •Because Enter values outside the range of the variable
- •1) Declaring Variables
- •2) Assigning values to the Variables
- •(Start – Dim - Byte – Integer – Boolean – String – Single)
- •If X , y , j , k , z values are as follows:
- •12. The result of the following Code is :
If X , y , j , k , z values are as follows:
X = 8 , Y = 2 , J = 3 , K = 4
Select the correct value of the variable Z after the execute of the following commands:
6 B) 7 C) 8
Q.14: What the value of variable “C” in the following code:
……… Mohamed ………………………………………………………..
Q.15: Choose from column (a) appropriate column (b):
column (a) |
column (b) |
||
1 |
If .. Then .. Else |
It is a part of the programming code and its result is “True / False”. |
(3) |
2 |
Try … Catch |
A conditional statement used to execute one of two options according to the result. |
(1) |
3 |
Conditional Expression |
A conditional statement used to execute only one option when it is True |
(5) |
4 |
Mod |
It is used to identify the errors which occur during the program runtime. |
(2) |
5 |
If … Then |
Is a mathematical operator that computes the remainder of a division expression. |
(4) |
Q.16: Put each word in the right place:
(Conditional Expression – Label2 – 50 – Try / Catch – False – Degree – TextBox2 - True)
If (N is divisible by M) the result of condition (N Mod M > 0) is False
Try / Catch is statement which is used to identify the error which the user may do during the program runtime and it enables the programmer to identify the error to the user.
To copy the contents of “TextBox2” and display them in “Label2”, the code should be: (Label2 .Text = TextBox2.Text )
In If conditional statement Conditional Expression comes following to If.
When (N = 10), (M = 20), the result of the conditional expression (N < M) will be True
Q.17: Rearrange the following code:
X = Me.TextBox1.Text (…2….)
Else (…5….)
MsgBox(“Success”) (…4….)
End If (…7….)
Dim X As Single (…1….)
If X >= 50 Then (…3….)
MsgBox(“Failed”) (…6….)
Q.18: Specify the value of each variable after executing the following Code.
N
If
X<Y
Then
Z
= K + J
X
= X + 1
Y
= Y - 1
Else
Z
= K - Y
X
= X + 2
Y
= Y - 2
End
If
Variable
Value
X
2
Y
1
Z
1
Q1: Choose the correct answer for each of the following:
1. What is the function of Next statement in the (For ..Next ) loop :
a) Increase the value of the counter variable with the increment value
b) Compare the increment value with the end value of the loop
c) All of the above
2. The best Loop used when you know in advance the number of iterations
a) Do while
b) For ..Next
c) Select ..case
3
.
After executing the following code what will be displayed in the
TextBox
(txt_display) is:
a) 2
b) 246810
c) 2345678910
4. After executing the following code what will be displayed in the Label
(
lbl_display)
is
a) 5
b) 10
c) 15
Q2: State whether the following statements are true (√) or false (X)
(1) |
The command Msgbox.”3” & “X” & “3” displays a message box containing number 9. |
( x ) |
(2) |
The value of (M) after the execution of the loop (For M=3 to 1 Step -1) is 0. |
( x ) |
(3) |
If you do not write (Step) with the (For ...Next) statement, it means that the increment value is zero; by default. |
( x ) |
(4) |
The value of (M) after the execution of the loop (For M=3 to 1 Step -1) is 0. |
( x ) |
(5) |
In For…Next command number of repetitions is known |
( √ ) |
(6) |
We should write the value of the increment step which is the increment amount in the counter when using For … Next statement |
( x ) |
(7) |
The start value of the counter in " For … Next " statement should be greater than the end value |
( x ) |
(8) |
In ( For … Next statement ) the iteration will continue until the counter value reach is to " End " value |
( √ ) |
(9) |
When the Counter value is equal to the End value then it will be the last time for repeating the required codes. |
( √ ) |
(10) |
The repetition times in the code (For N = 10 to 2 Step -2) is (4) times. |
( x ) |
(11) |
In For … Next statement, writing the value of the increment step is optional |
( √ ) |
(12) |
For I = 10 To 2 Step 2 is True code |
( x ) |
(13) |
Upon executing the assignment code M = 17 Mod 3, M value will be (2). |
( √ ) |
(14) |
For S = 21 To 3 Step -7 is True code. |
( √ ) |
(15) |
In For…Next command, start value, end value and step value are determined |
( √ ) |
(16) |
For I = 2 to 10 step 2, no. of repetitions for this code is 5 |
( √ ) |
(17) |
In For … Next statement, writing the value of the increment step is optional. |
( √ ) |
(18) |
The default value of the increment step in (For … Next) is (1). |
( √ ) |
(19) |
The value of Start or End in the Loop can’t be a decimal number |
( x ) |
(20) |
The Counter label cannot be typed beside Next at the end of For … Next statement |
( x ) |
(21) |
The Increment Step in For … Next code should not be more than (2) |
( x ) |
(22) |
The number of the repetition times in the code (For H = 1 To 2 Step 2) is two times |
( x ) |
(23) |
The number of the repetition times in the code: (For M = 1 To 2 Step 2) is two times. |
( x ) |
(24) |
The repetition times in the code (For S = 5 To 10) is (6) times |
( √ ) |
(25) |
The number of the repetition times in (For R = 1 To 7 Step 2) is 4 |
( √ ) |
(26) |
The counter label should be typed after Next at the end of the repetition. |
( x ) |
(27) |
The code Label1.Text = “ “ empting the contents of Label1. |
( √ ) |
Q3: What will be the value of the variable (r) after the execution of each of the following code?
|
( 10 – 5 – 0) |
Q.4: Complete the program to print even number from ( 0 to 100 ).
For N = ……0….. To ……100…….. Step ……2….
Print ……N…….
Next
Q5. : Express by " For … Next " repetition statement about the following :
I = ( 1 , 3 , 5 , 7 , 9 , 11 , 13 , 15 )
For I = 1 To 15 Step 2
I = ( 1 , 4 , 7 , 10 , 13 , 16 , 19 , 22 , 25 )
For I = 1 To 25 Step 3
I = ( 20 , 18 , 16 , 14 , 12 , 10 , 8 , 6 , 4 , 2 , 0 )
For I = 20 To 0 Step -2
N = ( 2 , 4 , 6 , 8 , 10 , 12 , 14 , 16 , 18 , 2o )
For N = 2 To 20 Step 2
N = ( 10 , 9 , 8 , 7 , 6 , 5 , 4 , 3 , 2 , 1 )
For N = 10 To 1 Step -1
Q.6: What are (S) values in the following codes:
For s = 1 to 15 Step 2
( 1 , 3 , 5 , 7 , 9 , 11 , 13 , 15 )
For s = 1 to 25 Step 3
( 1 , 4 , 7 , 10 , 13 , 16 , 19 , 22 , 25 )
For s = 20 to 0 Step -2
( 20 , 18 , 16 , 14 , 12 , 10 , 8 , 6 , 4 , 2 , 0 )
For s = 1.5 to 4.5 Step 0.5
( 1.5 , 2 , 2.5 , 3 , 3.5 , 4 , 4.5)
For s = 0 to 7
( 0 , 1 , 2 , 3 , 4 , 5 , 6 , 7 )
Q.7: Upon executing the following codes:
A
B
2
2 ^ 2 = 4
4
2 ^ 4 = 16
(A) value is ……4…..
(B) value is ……16…...
Q.8: Re-arrange the following steps correctly to calculate the total of the odd numbers from (1:8)
Q.9: Check the following codes giving the value of variable (X) every time it change:
I
X
0
0 + 6 = 6
1
1 + 6 = 7
2
2 + 7 = 9
3
3 + 9 = 12
Q.10: Choose the correct answer:
( 16 – 18 – 20)
Q
I
M
N
6
23
6
8
26
6
10
29
6
12
32
6
14
35
6
16
38
6
18
61
6
20
64
6
Q.12: Complete the following sentences
From the used statements in the iteration is For … Next Statement that the iterations number are known in advance
Q.13: Multiple choices Question:-
For I = 1 to 6 step 2, number of repetitions is:
A) 3 B) 4 C) 6
To change the value of the counter ( I ) like this (49, 42, 35, 28, 21) we use……….
(“For I = 49 to 21 step -7” - “For I = 49 to 21 step 7” - “For I = 21 to 49 step -7”)
When we don’t use step with For – Next, the counter value change with ………
( 1 - Zero - Doesn’t change )
4 - To display the odd numbers from 1 : 5 in Textbox1, the code is ………..
For y = 1 To 5
TextBox.Text = TextBox1.Text & Y Vbcrlf
For Y = 1 To 10 Step 2
Texbox. Text = Textbox1.text & Y & Vbcrlf
For y = 1 To 5 step 2
TextBox1.Text = TextBox1.Text & Y & Vbcrlf
5 - To make the variable (S) take the following values (8 – 17 – 26 – 35) orderly by using the code (For … Next), the code should be:
For S = 8 To 35 step 3
For S = 35 To 8 step -9
For S = 8 To 35 step 9
6 - The repetition times are known from the start in the repetition code ………
For … Next
Do While … Loop
If … Then … Else
7 - For I = 1 to 6 step 2, number of repetitions is:
A) 3 B) 4 C) 6
- Dim X As Integer = 5
Dim Y As Short = 6.2
Dim Z As Decimal
X = 2 * X
Z = X / 2
Z = Y + X
After executing the previous statements, the value of:
Y = ……… ( 6 - 6.2 - 5 )
Z = ……… ( 11.2 - 16 - 16.2 )
9- What is the value displayed in the Label control (LblOut) when running the following code.
Dim i as Integer
For i = 2 To 10 Step 2
lblOut.Text = lblOut.Text & i & ","
Next
a) 2 b) 2,3,4,5,6,7,8,9,10 c) 2,4,6,8,10
10- When you know in advance the number of iterations in a loop (a specific number of times) ; so the appropriate loop statement is :
a) For...Next b) If… End If c) Try … Catch
11- The iteration in the For ..Next statement ( For m=10 to 1 Step -2 ) stops when the value of the variable M:
a) Is greater than the end value
b) Is smaller than the end value
c) Is greater than or smaller than the end value