Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Question 1 When you declare a variable of type Single, it contains 0 by default.

ID: 3713298 • Letter: Q

Question

Question 1


When you declare a variable of type Single, it contains 0 by default.

True


False


Question 2


The following line declares an array that can contain whole numbers, with 10 elements.

Dim Variables(9) As Integer

True


False


Question 3


Once a variable is declared we can not change the variable's data type.

True


False


Question 4


If A is False and B is True, then A Or B is True because A is False.

True


False


Question 5


The data type of 25.5 is:


String


All shown answers are correct


Integer


Single


Question 6


The data type of 5 is:


Short


All shown answers are correct


Integer


Long


Question 7


The data type of the Text property is:


No correct answer is shown


Integer


String


Single


Question 8


Which of the following is a Boolean expression:

All answers shown are correct.


A Xor B



X

where X is integer

0


Question 9


To refer to a property xyz of a control named abc in your Visual Basic code, you use:


xyz.abc


a.b.c.x.y.z.


abc.xyz


No correct answer is shown


Question 10


Assume this code:

Dim Nums(Y) As Integer

Assume later we filled the array Nums with integer values.

Write one line of code that calculates the average of: the first and the last element of Nums. Display the average in a messagebox.

Question 11


Assume that an array z, is declared as in:


Dim z(n) As Integer

and that z has been filled with data in all its locations, and n is an odd number.

           <-- array content is integer values

0 1 2 3       n   <-- index or location

Write code that uses a for loop, to calculate the average of every other number in z starting from location 0 to location n inclusive.

Since n is an odd number the for loop can start at the first location and end at the last location of z.

Think of what the step should be so we process one element then skip the next one and move on to the one after that.

After the loop show the resulting average in a messagebox. Think about the number of elements we need to divide by is half of the elements between locations 0 and n.

Explanation / Answer

Question 1:

Single data type is used to floating point numbers in visual basic.single dataype allots 4 bytes in memory.the default value assigned to variable is '0'.

Hence answer is TRUE.

Question 2:

Arrays in visual basic are used to store the elements which are logically connected together.array can be declared in VB as dim variableName(5) As Integer.variableName is array name holds 5 elements.

As per the question, the variable name is 'Variable'.in Vb the first letter of the second word can be capital.the variable name cannot start with a capital letter.we can declare sam array as Dim Variable(9) As Integer;

in the questoion declaration is correct but variable name constrints are violated.

hence the answer is "FALSE".

Question 3:

In visual basic the variables can be converted to other datatypes if it neccessary.for example when a variable declared as single ,it can be extended to double.This conversion of datatypes can be implicit or explicit also.

In VB ,functions CBool,CInt etc are used to convert the datatype of the variable.

Hence the answer is "FALSE",

Question 4:

the question is on logical operator.as per the expression.if A is false and b is true,then A OR B is true.

because OR is a operator where any one of the expression is true then the entire statement become true.but not because A is false.its beccause B is true.

Hence the ansewer is " False"

question 5:

the value 25.5 is a floating number.

option a is not correct because the value is not declared as "25.5".its a normal float number not a string.

option b is not correct since its not string.

option c is not corrects its not Integer because it has a precision value.

Option D is the corrct answer.25.5 is single datatype value.

Question 6:

the value 7 is a natural number.

option a can be correct because the short datatype can be used to declare a natural number.

option a can be correct because the Integer datatype can be used to declare a natural number.

option a can be correct because the Long datatype can be used to declare a natural number

option b is correct since 7 is a natuaral number can be declared short,Integer and Long where the difference is in allocated size.

Question7:

String is the correct answer.text property is used to display the string in the form.so its datatype is not Integer or Single .It is String.

Question 8:

A Xor B is the boolean expression.when a statement said as boolean expression it should contain boolean operators like OR,AND Xor..

Question 9:

To refer a property of xyz of control named abc in VB code,we use abc.xyz.for example .

the syntax is as follows ControlName.propertyName.

example:text.Label, Font.size

Question 10:

Dim Nums(y) As Integer

MessageBox.show("(Nums(0)+Nums(y))/2")

(Nums(0)+Nums(y))/2 is the average of first and last no in array.and then average can be displayed in MessageBox by using show method.

Question 11:

code calculate the average of n=10 numbers in array z.

Dim a As Integer

Dim sum As Integer

Dim z(10)As Integer

Dim avg as Double

for a=0 to 10

sum+=a

next a

avg=sum/10

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote