Студопедия
Случайная страница | ТОМ-1 | ТОМ-2 | ТОМ-3
АрхитектураБиологияГеографияДругоеИностранные языки
ИнформатикаИсторияКультураЛитератураМатематика
МедицинаМеханикаОбразованиеОхрана трудаПедагогика
ПолитикаПравоПрограммированиеПсихологияРелигия
СоциологияСпортСтроительствоФизикаФилософия
ФинансыХимияЭкологияЭкономикаЭлектроника

Q2- Complete the following sentences:



Q2- Complete the following sentences:

1- The variable type Char is used to store single character in it

2- The variable type Boolean is used to when choosing true or false

3- The variables types Single, Double are used for storing the values which contain decimals

4- The variable type Byte is used for storing values in the form of integers and it takes a less space the memory to storing.

5- The result of the arithmetic operation H*3+7 when H = 4 is 19

Q.3- Choose the correct Answer:

1- You can use word …………. To announce the names of the variables in the program.

(Start – Dim – End)

2- The following words of the types of variables except the word.

(Me – Byte – Single)

3- The numeric variable that stores only whole numbers from 0 – 255 is of data type

(Byte – Integer – String)

4- A variable of type (Boolean – Integer – String) stores the values true\false.

5- To store a digit with decimal points (fractions) we use a variable of data type

(Integer – Short – Single).

6- To end “Try … Catch” statement, use:

(Stop Try – End Try – Stop Catch)

7- To store whole numbers only we use a variable of data type (Single – Double - Integer).

8- Use code ……………. To detect errors that occurs while the program is running and handling.

(Catch – End Try – Try/Catch)

9- On executing the equation (4*3+2), the result will be (9 - 20 - 14).

10- The result of the arithmetic operation (2^3+1) is (10 – 16 – 9).

11- When executing the following code: Dim X As Integer = 3/2, X value is:

(1 – 1.5 – 0.05 - 2)

12- The ………….. sign is called the assignment operator.

(“ “ - “ * “ - “ = “)

13- Using ………… as a variable name will be incorrect.

(23 world war – 1/1/1990 – Double - All the previous)

14- From the statement (H = 22 Mod 7) it appears that (H) value is …………

(A. (H=3) - B. (H=5) - C. (H=1))

15- After executing the assignment code: N = 21 / (3 + 2 * 2), N value is:

(13 – 30 – 3 – [-3])

16- When executing the code: Dim S As Integer = 6.4: MsgBox(S), is:

(0.7 – 6.7 – 6 – 7)

17- ………………… error is the result of the user input of incorrect values.

(Syntax – Logical – Runtime)

18- When A = 5, B = 2 the result of (5 * 6 – A ^ B) is …………..

(5 – 35 – 10 – 50)

19- What is the value displayed in (label) control, when executing the following code:

Dim intNum As Integer = 10

intNum = intNum + 2

intNum = intNum Mod 3

Label1.Text = intNum

a) 3 b) 0 c) 4

20- Assigning values to constants is done:

a ) When you declare constants only.

b) During the implementation of program’s instructions.

c) When you declare constants as well as during the implementation of program’s instructions.

21- Select the result of the following Arithmetic expression: 2 * (7+2) - 2

a) 16 b) 14 c) 5

Q.4: Write the programming code for the following:

1- Declaring a constant name “BD” for storing the date “1/1/2010”.

Const BD As Date = #1/1/2010#

2- Declaring a decimal constant “A1” for storing the value 85.50

Const A1 As Single = 85.50

3- Declaring a constant name “D” for storing the value 32000

Const D As Short = 32000

4- Declaring a variable name “U_Name” for storing characters.

Dim U_Name As String

5- Declare two variables (W, L) as a non integers

Dim W, L As Single

Q5: Match from the first column with the suitable in the second column:

A

B

 

Byte – Short – Integer - Long

Data types for storing integer and decimal

(4)

 

Declaring Constants

It is used in Visual Basic.Net to link text values.

(3)

 

(&) Sign

Data types for storing integer.

(1)

 

Single – Double – Decimal

Variable Name or Property = Value

(6)

 

Declaring Variables

Const Constant Name As Constant Type = Value

(2)

 

Assignment Statement

Dim A1_Mostakbal As String

(5)

Q6: Correct the underline:

1) To set line as a comment not be executed when starting the program, type Dim at the start of the line in the code window.

…………………………………………………………………………….. REM …………



2) To save the student age uses the variable String.

……………………………………… Byte or Single ……………………………………..

3) To save data containing decimals and keep them without approximation we use the Long data type.

……………………………………………………………………………………… Single

Q7: Second: In the following code, get the variable names and constants and their Data Types.

Variable Names

Type

Radius

Single

Constant Names

Type

X

Single

Q8: Determine the type of error in the following, and then perform the required error handling.

Code

error type

error handling

Din x As Single

Syntax Error

Dim

Const x As Single

Syntax Error

Const x As Single = value

Q9: When writing code the user needs to add specific comment that will not be executed, so the code must be preceded by:

1. REM

OR

2. (‘)

Q12: Put each word in the right place:

(Start – Dim - Byte – Integer – Boolean – String – Single)

1- We are used variable of type Single to put the degrees of subjects.

2- Variables are declared using the word Dim

3- We are used variable of type String to put the student’s name.

4- The type of variables Integer used to store integer only.

5- Variable of type Boolean takes the value True or False.

6- The variable Byte Takes the values (0: 255).

Q13: Give the suitable term to the following sentences:

1- Data type for storing date and time. (Date)

2- Data type for storing (String and characters) values. (String)

3- Data type in the form of an object. (Object)

4- Data type for storing logical values. (Boolean)

5- It is stored in Visual Basic.Net and it indicates to the current Form window. (Me)

6- Data type takes value in the border of (0 To 255). (Byte)

7- It is typed in the start of the line in the Form window for typing a comment or note. (REM)

8- It is statement that consists of two sides (right hand side and left hand side) separated by the assignment operator “=”; which doesn’t mean the arithmetic equality. And it enables to store a value in a variable or property. (assignment Statement)

9- It means the errors which occur when typing the codes incorrectly in the code window as “characters errors”. (Syntax error)

10- A guiding word for creating a new line. (Vbcrlf)

11- It is a statement which is used for discovering the errors which occurs during the program runtime. (Try / Catch)

12- A code for defining the constant name, type and value. (Declare of Constant)

13- They are errors that occur as a result of the user entering incorrect values during the program runtime. (Runtime error)

14- The word is used to announce the names of the constants in the program. (Const)

15- It is used to link literal values together and make one value. (&)

Q14: What is the result of executing the following code?

1-

- Dim N1 As Byte = 3: N2 As Byte = 2: N3 As Byte = 5

 

A) N2 ^ 2 * N3

………20……………………………………………………

B) N1 * (N3 – 2) ^ 2 * N2 ^ 2

……… 108 ………………………………………………

C) N1 * (N2 + 3)

…… 15 ……………………………………………………

2-

- Dim U_B As string

TextBox2.Text = “I like”

U_B = TextBox2.Text & “ “ & “ Egypt”

…… I like Egypt ……………………………………………………

Q15: What is the result of executing the following equations?

1) 2 ^ 3 + (23 + 2) / 5

……………13…………………………………….

2) 3 ^ 2 *2 + 4 + 3

…………25……………………………………….

3) 3 ^ 2 + (2 + 4)

…………15……………………………………….

4) (3 + 2 ^ 2) * 3 / 7

…………3……………………………………….

5) 4 * 3 + 5 * 2 ^ 2

…………32……………………………………….

Q16: What is the wrong in each of the following codes?

1) Dim number1 As Integer

Number = (4 * 3 ^ 2) / (3 – 9 / 3)

……………………You cannot divide by Zero…………………………

Q1: State whether the following statements are true (T) or false (F):

(1)

The number of possible branches when using (If...Then..Else) statement is 2.

()

(2)

In (IF) statement the code that follows (Else) is executed when the result of the conditional expression is (True).

(X)

(3)

The operator (&) is one of the logical comparison operators.

(X)

(4)

The result of (80 <= 60) conditional expression is False.

()

(5)

The result of the conditional expression (12 Mod 6 = 2) is True.

(X)

(6)

The use of (Else) keyword is optional in (If) statement.

()

(7)

The result of the function (IsNumeric) is always (True) or (False).

()

(8)

The value of the expression (4 < > 4) is false.

()

(9)

The value of the conditional expression could be "True" or "False" and that depends on the result of the conditional relation

()

(10)

The result (90 <=30) conditional expression is False.

()

(11)

The result of the conditional expression (12 Mod 3) = 30 is false.

()

(12)

IsNumeric Function uses two parameters.

()

(13)

In (If…Then…Else) statement, when the outcome of the condition is evaluated to be False then the statements following (Then) are executed.

(X)

1.

The conditional statement (If) can be used set the order of the codes during the program runtime.

()

2.

The result of the following code is “False:

Dim S As Single = 21

MsgBox(IsNumeric(S))

(X)

3.

(IsNumeric) statement has logical value (True / False).

()

4.

If conditional statement has one form only.

(X)

5.

In (If … Then … Else If) statement the codes after True are executed while the other codes and conditions are ignored.

()

6.

The code < > is of the Comparison factors.

()

7.

When typing If conditional statement in one line, we will need to type End If.

(X)

8.

The result of (50 <= 35) conditional expression is True.

(X)

Q2:

The following code calculates the area of a circle of radius (R).Rewrite this code in left column so that; the message “ Not Allowed “will be displayed; when you enter a negative number in (TextBox1); whose value is assigned to variable (R).

 

Dim r, area As Single

Const pi AsSingle = 22 / 7

r = Me. TextBox1.Text

If r < 0 Then

MsgBox (“ Not Allowed”)

Else

area = pi * r ^ 2

MsgBox (“area of circle= “ & area)

End If

 

 

Q3: The following code is written to solve the first degree equation (y = 3x + 2) and gives correct results when you enter numeric values in the (TextBox); but an error occurred while running (Runtime Error) when you entered string values in the (TextBox). Write the code after solving this problem using an additional (If) statement, that displays the message " You must enter a positive numerical values " in a (label) control.

Dim x, y As Single

If IsNumeric (Me.TextBox1.Text) Then

x = Me.TextBox1.Text

y = 3 * x + 2

label1.Text = y

Else

Label1.Text = “ You must enter numerical values”

End If

Q4: Choose the result of executing each of the following codes:

S

The code

The result

 

a. One

b. Two

c. three

 

a. True

b. False

c. 15

 

a. Youssif

Ahmed

b. Ahmed

Youssif

c. Ahmed

 

 

a. AXB=63

b. 7X9=63

c. 7X9=A*B

Q.6: Give the result of each of the following codes:

1. MsgBox (IsNumeric (“Ahmed”)) (False)

2. MsgBox (Isnumeric (30)) (True)

3. Label1.Text = IsNumeric (“One”) (False)

4. Dim H As Single = 5 // MsgBox (IsNumeric (H)) (True)

5. TextBox1.Text = “7” MsgBox (IsNumeric (TextBox1.Text)) (False)

Q.7- If Variable A = 20 and variable B = 15;

Put (ü) or (X) for the following statements

1. Evaluation of condition A < > B is False (X)

2. Evaluation of condition B < A – B is True (X)

3. Evaluation of condition B >= A – 5 is True (ü)

Q8- Read the following code; after code execution, choose the correct answer:

Age = 25.5

Mark = 90

If Age < 26 Then

Age = 16

Mark = 100

End If

Total=Mark*2

1. Value of variable Age = …(A. 25.5 - B. 90 - C. 16)

2. Value of variable Mark = …(A. 90 - B. 100 - C. 25.5)

3. Evaluation of the condition Age < 26 is … (A. True - B. False - C. 25.5)

4. Value of variable Total is …. (A. 200 - B. 180 - C. 190)

Q.9: Rewrite the following sentences after correcting the underlined:

1. Focus function is used to determine whether the value is digital or not.

IsNumeric ………………………………………………………………………..

2. MessageBox (TextBox1.Text)

……MsgBox………………………………………………………………………..

3. Dim N As Integer = “Egypt”.

…………String…………………………………………………………..

 

Q.12: Complete the following sentences from between the bracets:

(Attention – Focus – True – Try/Catch – IsNumeric - > - False - < = - MsgBox)

1- Try/Catch is a statement which is used to identify the errors which the user may do during the program runtime and it enables the programmer to identify the error to the user.

2- IsNumeric is a function which is used to identify the digits values.

3- TextBox1.Focus moves Attention to TextBox1.

4- MsgBox IsNumeric (90) displays a message containing True

5- Using ………>……… factor results in errors in the operation when the values of the left side is less than the right one.

6- Focus method is used to move the concentration to TextBox.

7- If (H is divisible by Y) the result of the condition (H mod Y < > 0) is False

8- To view a MessageBox including the statement (Egypt is my great love), the code will be MsgBox (“Egypt is my great love”).

Q.13:

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:

 
 

 

 


A) 6 B) 7 C) 8

 

 

Q.15: Choose from column (a) appropriate column (b):

column (a)

column (b)

 

If.. Then.. Else

It is a part of the programming code and its result is “True / False”.

(3)

 

Try … Catch

A conditional statement used to execute one of two options according to the result.

(1)

 

Conditional Expression

A conditional statement used to execute only one option when it is True

(5)

 

Mod

It is used to identify the errors which occur during the program runtime.

(2)

 

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)

1- If (N is divisible by M) the result of condition (N Mod M > 0) is False

2- 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.

3- To copy the contents of “TextBox2” and display them in “Label2”, the code should be: (Label2. Text = TextBox2. Text)

4- In If conditional statement Conditional Expression comes following to If.

5- 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.

Variable

Value

X

 

Y

 

Z

 

 

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

Note: That the primary values of the variables are (x = 0, Z = 0, J = 1, K = 1, Y = 2)

 
 


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).

1- For N = ……0….. To ……100…….. Step ……2….

2- Print ……N…….

3- Next

Q5.: Express by " For … Next " repetition statement about the following:

1. I = (1, 3, 5, 7, 9, 11, 13, 15)

For I = 1 To 15 Step 2

2. I = (1, 4, 7, 10, 13, 16, 19, 22, 25)

For I = 1 To 25 Step 3

3. I = (20, 18, 16, 14, 12, 10, 8, 6, 4, 2, 0)

For I = 20 To 0 Step -2

4. N = (2, 4, 6, 8, 10, 12, 14, 16, 18, 2o)

For N = 2 To 20 Step 2

5. 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:

1. For s = 1 to 15 Step 2

(1, 3, 5, 7, 9, 11, 13, 15)

2. For s = 1 to 25 Step 3

(1, 4, 7, 10, 13, 16, 19, 22, 25)

3. For s = 20 to 0 Step -2

(20, 18, 16, 14, 12, 10, 8, 6, 4, 2, 0)

4. For s = 1.5 to 4.5 Step 0.5

(1.5, 2, 2.5, 3, 3.5, 4, 4.5)

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 = 4

 

2 ^ 4 = 16

 

 

 


1) (A) value is ……4…..

2) (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 + 6 = 6

 

1 + 6 = 7

 

2 + 7 = 9

 

3 + 9 = 12

 

 

 


Q.10: Choose the correct answer:

 

 


(16 – 18 – 20)

I

M

N

     
     
     
     
     
     
     
     

 

Q.11: What will be the value of variables (M) and (N)after the execution of the following code?

 
 


Q.12: Complete the following sentences

1- From the used statements in the iteration is For … Next Statement that the iterations number are known in advance

Q.13: Multiple choices Question:-

1- For I = 1 to 6 step 2, number of repetitions is:

A) 3 B) 4 C) 6

2- 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”)

3- 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 ………..

A) For y = 1 To 5

TextBox.Text = TextBox1.Text & Y Vbcrlf

B) For Y = 1 To 10 Step 2

Texbox. Text = Textbox1.text & Y & Vbcrlf

C) 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:

A) For S = 8 To 35 step 3

B) For S = 35 To 8 step -9

C) For S = 8 To 35 step 9

6 - The repetition times are known from the start in the repetition code ………

A) For … Next

B) Do While … Loop

C) If … Then … Else

7 - For I = 1 to 6 step 2, number of repetitions is:

A) 3 B) 4 C) 6

 

8 - 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:

a) Y = ……… (6 - 6.2 - 5)

b) 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

12. The result of the following Code is:

Dim N As Integer Dim S As Integer For N = 1 to 100 S=S +N Next Label1.Text = S

a) Displaying the numbers from 1 to 100.

b) Displaying the sum of the numbers from 1 to 100.

c) Displaying the product of the numbers from 1 to 100.

I

X

 

4.5*2 = 9

 

9*2 = 18

 

18*2 = 36

 

Q.13: Trace the following code segment, showing the value of each variable each time it changes:

1- X = 4.5

2- For I = 0 To 7 Step 3

3- X = X * 2

4- Next

Q.14: Upon executing the following codes:

-

H

R

   
   
   

 

Dim H, R As Integer

- For H = 0 To 5 Step 2

- R = 2^H

- Next

a) (H) Value is …………...…..…..

b) (R) Value is …………..………..

Q.15: Third: Answer the following

1- Specify the value of each variable after executing the following Code.

Dim N, K, C As Integer

C = 10

For N = 1 To 10 Step 5

K = K + N

Next

If N >= C Then

C = C + 1

End If

Variable

Value

C

 

K

 

N

 

 


Дата добавления: 2015-10-21; просмотров: 16 | Нарушение авторских прав




<== предыдущая лекция | следующая лекция ==>
 | 1. When an atom gives an electron or more, it becomes a positive ion.

mybiblioteka.su - 2015-2024 год. (0.152 сек.)