Chapter 1: Representing Data
|
|
- Osborn Harrington
- 5 years ago
- Views:
Transcription
1 - ١ -
2 Chapter 1: Representing Data Data Variables and Constants When you input data into a computer, the computer stores it in its memory 1- Computer's memory consider as millions of little boxes. 2- Each little box has a number, starting at box number zero. 3- The actual number of boxes in your computer depends upon the size of memory. Each memory location (each box ) can hold a byte, where the byte can store a single character or can store an integer number. If the number you want to store is greater than the maximum value, you have to store it in a number of memory. Visual Basic allow you to set up locations in memory and give each group of locations a name. For example: 1- Quantity is the name of a memory locations that hold the number of books. 2- Unit Price is the name of memory locations that hold the price of a single book. 3- Price is the name of memory locations that hold the price of all the books. Quantity, Unit Price, and Price are variables. Variables: Memory locations that hold data that can be changed during program execution Constants: Memory locations that hold data that can not be changed like sales tax rate or Π ( 3.14 ) Note: We used ' Dim ' just once to declare each variable. Data Types Representing data as sequences of Ones and Zeros. - ٢ -
3 The data type of a variable or constant indicates the type of information that will be stored in the allocated memory space, where the size of the memory space allocated for each type is different. The standard data types : 1- Number of Bytes shows the number of bytes of main memory. 2- Range refers to the largest and smallest values that can be stored in a numeric variable Data Type Number of Bytes Precision Boolean 2 Not Applicable Byte 1 Whole numbers only Char 2 Not Applicable Date 8 Not Applicable Decimal digits Single 4 7 significant digits Double 8 15 significant digits Short 2 5 digits whole numbers only Integer 4 10 digits; Whole numbers only Long 8 19 digits; whole numbers only String Varies Not Applicable Note : Type Integer, Long, and Short can store only( integer values ). Type Decimal, Single, and Double store ( fractional values ). Variable Type Explanation SingQuantity Single Maximum Precision of 7 significant digits is reached DoubQuantity Double Maximum Precision of 15 significant digits is reached DecQuantity, Decimal The whole number is stored because the number is 17 digit where the precision for Decimal is 29 digits. Naming Rules A programmer has to name ( identify ) the variables and constants that will be used in a project according to the following rules : a- Names may consist of letters, digits, and under scores. - ٣ -
4 b- Names must begin with a letter. c- Names cannot contain any spaces or periods. d- Names must not be reserved words.( such as print, Dim, double, and Data ) Note : It is better to use the following Naming Conventions a- Identifiers should be meaningful. For Example to name an identifier the average, just call it average. b- Capitalize each successive word of the name. For Example to name a variable " hours worked ", write the name as " Hours Worked". The Identifiers in VB are not case sensitive. There fore the names hoursworked, Hours worked, and hoursworked refer to the same variable. For Example: The following list shows examples of valid variable names : First Name Ahmed 2000 Population of Egypt Spent Money The following list shows some invalid variable names : Variable Name Cause of Invalidation of Variable Name 2 nd World War Variable name must start with character Spent. Money Variable name contains period Birth Day Variable name contains space Double Variable name is a reserved word Choosing the appropriate data type for a variable The following table contains a set of decision rules, to select the best type for that variable. Nature of value to be stored - ٤ - Appropriate Type Reason Something that is True or False Boolean Most efficient storage Sequence of characters that are not involved in arithmetic String The only choice Money Amount Decimal Can store pound and piaster with no round off error ;
5 fast arithmetic Whole Number <=Number<= ,147,483,648<=Number <=2,147,483,647 Number >2,147,483,647 Short Integer Long Less Memory faster arithmetic than other numeric types Less memory and faster than Log Number with fractional part -(10) 38 <Number<(10) 38 or Seven digits of significance Single Faster arithmetic than Double Number >(10) 38 or more than Seven digits of significance Double Constants Constants provide a way to use words to describe a value that does not change. Visual Basic.NET has two types of constants: Intrinsic constants and Named constants 1- Intrinsic constants Intrinsic Constants are built into. NET framework. Visual Basic provides an easy way to specify a large number of colors. Color.Black Color.Blue Color. Red Variables Declaring a Variable using { Dim Statement } To create a variable 1- You write a variable declaration which begins with the keyword " Dim ". 2- The name of the variable to be declared. 3- The keyword " As ". 4- The data type for the variable finally an optional equal sign and initial value. - Dim Child Weight as Integer. - ٥ -
6 - Dim Population as Integer. - Dim Student Name as String - Dim My Address as String = " 102, Salah Salem, Cairo " Declaring multiple variables using one Dim statement. You can declare multiple variables using a single Dim Statement. For example : Dim Child Weight, Population as Integer Dim UnitPrice as Decimal = 123, My Address as String = " 102, Salah Salem, Cairo " Dim Student Name as String The assignment Statements : To change the value stored in a variable you have to use an assignment statement. Variable Name = Expression Note : You have to create the variable using variable declaration statement before you can use it in an assignment Statement. For Example you can write the following assignment statement in programming Count = Count + 1 The new value of Count is equal to the previous value of count plus 1 but In mathematics this equation is wrong because if we subtract count from both sides we will get a value 1. To execute an assignment statement, the computer does two steps : a. Determines the value of the expression on the right-hand side of the assignment sign by i- Replacing the constant names and variable names by their values. ii- Executing the needed operations. b. Store the value of the expression in the variable whose name is on the left-hand side of the assignment sign. For Example : The following assignment statement : Statement Quantity Unit Price Price Tax rate 4 Bytes 16 Bytes 16 Bytes 16 Bytes Dim Quantity As Integer = Doesn't exist Doesn't exist Doesn't exist Dim Unit Price As Decimal = Doesn't exist Doesn't exist - ٦ -
7 Price = Quantity * Unit Price *5.5= The computer executes this assignment statement as follows : Exercise 1: a- It determines the value of the expression as follows : 1- Replacing Quantity, Unit Price by 100 and 5.5 respectively. As a result of this expression will look as follows : 100* Executing the multiplication. As a result of this the expression value will be equal to 55.0 b- It stores the value of the expression (550.0 ) in Price. 1- We stored the value of 20 into the variable count. 2- The computer replaces variable name count to the right-hand side by its value (20) 3- As a result of this the expression will be equal to The computer will store 21 into the variable on the left-hand side. That means that the new value of count will be 21. Trace the following piece of code Dim X As Short Dim Y As Short Dim Z As Short X = 10 X = 2 * X + 1 Y = X-8 Z = Y / 3 Z = Z + 4 Note that tracing means showing the contents of all variables for every statement. Solution Statement X Y Z Dim X As Short 0 Does not exist Does not exist Dim Y As Short 0 0 Does not exist Dim Z As Short X= X=2*X Y=X Z=Y/ Z=Z ٧ -
8 Note that : 1- The 7 th. Statement is the division of 13 by 4 which Exact result is Because Z is an integer variable, only the value of 3 will be stored in it. 2- The value of 0.25 will be neglected. Important : If you want to store the floating point number 3.25 in Z, you have to change its type into single, Double, or Decimal data type. The Assignment Statements for Strings : You can use the assignment statement to store the result of string manipulations into a string variable just as you store the result of arithmetic calculations in a numeric variable Exercise 2 Trace the following piece of code : Dim First name As String Dim Last Name As String Dim Message As String First Name = " Hany " Last name = " Ahmed" Message = "Welcome " & First Name & " Last name " Solution Statement First name Last name Message Dim First name As String Does not exist Does not exist Dim Last Name As String Does not exist Dim Message As String First name = " Hany " " Hany " Message = " Wlecome" & First Name & & Last Name " Hany " "Ahmed" " Welcome Hany Ahmed " Note: means an empty string, where means a string that contains a number of spaces Arithmetic Operations The following table shows the arithmetic operations that - ٨ -
9 Operator Operation + Addition - Subtraction * Multiplication / Disision \ Integer Division Mod Modulus ( Remainder of division ) ^ Exponentiation Important Note : A- The Integer division and the Modulus ( Remainder of division ) If we divide 48 5 = 9 3 / 5 1- Integer division 48 / 5 = 9 2- Reminder of the division 98 Mod 5 = 3 B- The Exponentiation Exponentiation operator ( ^ ) raises a number to the power specified the returned ( Produced ) value is type Double For example, if x = 5, then y = x ^ 2, 25.0 where has to be of type Double. Exercise : Create a project that contains a single form which " Name " property is " Form 1 ". " Form 1. Text" must be set to " Math ". The form hosts two text Boxes txtfirst, and txt Second The results of addition, subtraction, multiplication, division, integer division, modulus, and exponentiation of the contents of the two text Boxes' are Solution : 1- Plan the project : The first step in planning is to design the user interface. 2- Creating your VB project : ( Choose New Project from the Visual Studio main menu, or double click " Create Project " in the " Recent Projects " pane ) 3- In the Project types pane choose windows and in Templates pane double click windows application. - ٩ -
10 4- Type the name you want of your project " Math ". 5- Click OK. 6- Set up the form (Resize the form in the document window : Drag the resize Handles to make the suitable size ). 7- Place controls on the form " Form 1 " After placing the two text Boxes, the 16 label, and the button, we have to change the properties needed for each control. Name Property Setting Txt Box1, txt Box 2 Text Text Align Font Font Style Font Size Center Microsoft Sans Serif Bold 10 IbiLable 1 Text & First IBI Label 2 Text & Second IBiLabel 1 thhrough IBILabel 7 Text Fixed 3 D Border Stype Ibi Add, Ibi Sub, IbI Mul, Ibi Div, Ibi Int Div, Ibi Mod, IbI Exp Text +, -, *, /, \ Mod, ^ Button 1 Text Calculate 8- Align the controls on the Form : 9- Double click on Button 1. (This will open up the Code window and also create the first and last statements of the Click Event Handler) - ١٠ -
11 Public class Form l Private, sub Button 1 click ( By Va 1 sender As system. Object, By Vale As system. Event Args ) Handless Button. click 'Declare the local variables 1 Dim First, seond, ad, subtract, Mul, Div, Div2 As Decimal 2 Dim Modulus As Integer 3 Dim Expon As Double 'Convert the text strings to decimal 4 First = Decimal, Parse (Me txt first. text ) 5 Second = Decimal Parse (me txt Second. Text ) 'Calculate the values of local variables 6 ad = first + Second 7 Ibl Add. text = ad. To String ( ) 8 Subtract = first second 9 Ibi Sub. Text = subtract. To String ( ) 10 Mul = first * Second 11 Ibi Mul. txt = Mul. To string 12 Div = First / second 13 IBIDiv. Text = Div. To String ( ) 14 Div 2 = first / second 15 IBI Int Div. Text = Div 2 To String ( ) 16 Modulus = first Mod Second 17 IBI Mod. Text = Modulus. To String ( ) 18 Expon = first ^ second 19 IBI Exp. Text = Expon. To String ( ) 20 End Sub End Class 10- Enter any nonnumeric values. The program will stop and an error message will be displayed. - ١١ -
12 Precedence of Operations The Operations are performed determines the result * 2 The rules of Precedence for evaluation of an expression is performed in the following order from highest to lowest : 1. Operations within parentheses. 2. Exponentiations. 3. Multiplication and division operations 4. Integer division operations. 5. Modulus operations. 6. Addition and subtraction operations Multiple operations at the same level ( such as multiplication and division ) are performed left to right. Exercise : What is the result of evaluation of the following expressions? Assume that x Integer = 2 yinteger = 3 zinteger = 4 Solution : i- x Integer * ( y Integer + 1 ) is replaced by 2 * ( ) the parenthesis is evaluated first giving 2 * 4 then, the multiplication is performed giving 8 the result ii- Y Integer ^ x Integer * x Integer + z Integer * 3 is replaced by 3 2 * * 3 the exponentiation is evaluated first 9 * * 3 the multiplication at the left is performed giving *3 the multiplication at the right is performed giving the addition is performed 30 the result - ١٢ -
13 Questions A) Multiple choice questions : 1. The conversion from a narrower numeric data type to another one which is wider is referred to as a ( n ) implicit conversion. 2. The zero value is represented by in V B. 3. Which of the following declares three Integer and two string variables? Dim N1, N2, N3 As Integer, S1 S 2 As String 4. When a value is placed in a memory location, the value replaces the previous contents of the memory location. 5. When a value is read from a memory location, the value is not affected. 6. The expression to the right of the assignment operator = is evaluated before the assignment occurs. 7. The( \ )operator performs Integer division. 8. Variable declarations begin with the keyword Dim. 9. The To String function converts a numeric value into a string type. 10. Arithmetic expressions are evaluated from highest level of precedence to the lowest level of precedence. B) The code in Figure 1-8 modifies variables num 1, num 2 and num 3. Trace the given code showing the contents of all variables for each step, given that num 1, num 2 and num 3 are equal to 1,2 and 3 respectively. Dim num1, num 2, num 3 As Integer num 3 = num 1 + num 2 + num 3 num 3 = num 3 Mod 3 num 2 = num num 1 = 4 num 2 = num 1 3 num 1 = num 1 + num 1 num 2 = num1 + num 3 num 2 = 5 * num 2 \ num1-١٣ -
14 Statement Num 1 num 2 Num 3 Dim Num 1, Num 2, Num 3 as Integer Num 3 + Num 1 + Num 2 + Num Num 3 + num 3 Mod Num 2 = num Num 1= Num 2 = Num Num 1= num 1 + num Num 2 = num 2 + num Num 2 = 5 * num 2 / num 1 8 5/8 0,625 zero 0 C) What is wrong with the expression shown in Figure Dim number 1 As Integer Number 1 = ( 4 * 3 ^ 2 ) / ( 10 Mod 3 1 ) Dim number 1 as integer Number 1 = ( 4 * 3 ^ 2 ) / ( 10 Mod 3 1 ) * Brackets First : ( 4 * 9 ) / ( 1 1 ) 36 / 0 = The error is We can't divide any number over Zero. D) Project Create a project that contains a single form which " Name " Property is " Form 1 " which text property is set to " Average ". The form hosts three Text Boxes txt First, txt Second and txt Third. In addition to that the form hosts one button and five labels as shown in Figure 1-10 you have to enter three decimal numbers in the three text boxes. The average of the three numbers has to be displayed in label ١٤ -
15 Chapter 2: Condition and Decisions Using Conditional Expressions A conditional expression is an expression that asks a True-or-False question about a variable, a property, or a piece of data in the program code. For example, the conditional expression Score > 90 Means: is the score more than 90? This expression evaluates to True if the Score is more than 90, otherwise it evaluates to False. Symbol Relation Tested Example Result > Greater than A >B False < Less than A < B True = Equal to A = B False < > Not equal to A< >B True > = Greater than or equal to A > = B False < = Less than or equal to A< = B True If Then Else Statement. A decision made by a computer depends on the result of the question : Is a given condition True or False? If it is True, do one thing ; it is False do something else. This can be seen in the Flow Chart. - ١٥ -
16 The outcome of the condition is evaluated to be True or False - If the outcome is True : the computer executes statement block 1, then skips to the statement following End If. - If the outcome is False : the computer executes statement block 2, then executes the statement following End If. The syntax of the If Then Else statement If condition then Statement block 1 Else Statement block 2 End If For Example Write a program that can calculate the weekly salary of an employee. If his working hours is less than or equal to 40 hours, his salary is 5 L. E. If his working hours is greater than 40 hours, his salary is calculated as follows : i- Five pounds / hour for the first Forty hours. ii- Ten pounds / hour for working hours greater then 40. That means that his salary = 40 * * ( working hours 40 ) - ١٦ -
17 If Hours worked > 40 then Over Time = 10 * ( Hours Worked 40 ) Salary = 40 * 5 + Over Time Else Salary = 5 * Hours Worked End If Msg Box ( " The salary is equal to " & Salary ) - ١٧ -
18 Simple If Then Statement Note : 1. If.. Then statement is a simplified version of the If Then.. Else statement. 2. If.. Then.. Else is useful when the two outcomes execute either action A or action B 3. If..Then statement is useful when the two outcomes execute either action A or no action. The effect of the If. Then statement as follows : The outcome of evaluating the condition can be either True or False. - If the outcome is True : the computer executes statement block 1, then skips to the statement following End If. - If False : The computer skips immediately to the statement following End If. If condition Then End If Statement block 1 For Example If Age > 16 Then Msg Box (" You can get an ID card " ) End If - ١٨ -
19 If Then.. Else statement General Form Note : The conditional expressions are evaluated from the top downward. Compound Conditions Compound conditions can be used to test more than one condition. You can create compound condition by joining more than one condition using logical operators. [ Or, Or Else, And, And Also, Xor ( exclusive Or ), and Note ] Logical operator If condition 1 Then Statement block 1 Else If conditions 2 Then Statement block 2... Else Astatement block2 End if Meaning Example Result or If one condition or both conditions are True, the compound condition is True. firstinteger = 50 Or secondinteger > 200 True Or False True And Both conditions must be True to get the compound condition equal to True. FirstInteger <= 50 And secondinteger < 200 True And False False Note : 2 Items are True and 4 Items one false Important Note First Second Logical Operator Condition Condition And Or T T T T F T F T T F F T F F F F T F Not ( T ) = F Not ( F ) = T - ١٩ -
20 Comparing Strings : We can compare string variables to other string variables, string literals enclosed in quotation marks, or string properties. The ranking of the characters is based on the code used to store characters in the computer. The code called ANSI code ( American National Standards Institute code ) Note : 1- The code of letter A is less than the code of letter Z ( A = 65, B = 66, C = 67 Z = 90 ) 2- The numeric digits ane less than letters. 3- The Start of code is space = 32 When the end of code is Del = 127 For more information see table 2-5 Page 60 For Example : 1- txtperson1.text = "NEHAD", txtperson2.text = " NEHAL " 2-1b1Street1.Text = "SALAH SALEM", Ib1Street2.Text = "SALAH" 3- Ib1 Car 1 text = " Cairo ", Ib 1 Car 2. Text = " Nasr " 4- txtname1.text = "ahmed", txtname2.text = "Ahmed " i. txtperson1.text < txtperson2.text ii Ib1Street1.Text < Ib1Street2.Text iii. Ib1Car1.Text < Ib1Car2.Text iv. txtname1.text < textname2.text Solution : 1. The condition txtperson1.text < txtperson2.text evaluates True because the D in NEHAD is lower ranking than the L in NEHAL. 2. The condition Ib1Street1.Text < IB1Street2.text evaluates False because when one string is shorter than the other, we compare them as if the shorter string was padded with blanks to the right of the string, we are comparing the two strings : "SALAH SALEM" and "SALAH" Which results that "SALAH SALEM" is more than "SALAH " Because S in SALEM is higher rank than the corresponding space in " SALAH " 3. The condition Ib1Car1.Text < Ib1Car2.Text evaluates True because the number 8 is compared to letter N and 8 is lower than N. 4. The condition txtname1.text < txtname2.text evaluates False because the a in Ahmed have a higher ranking than A. - ٢٠ -
21 Using IF Statements with Radio Buttons, Check Boxes, and Group Box Controls Radio Button control Check Box control Group Box control presents the user with a set of options from which to select just one option Radio Button Controls : presents the user with a set of options from which to select any number of options at the same time - ٢١ - allows the developer to group the Radio Buttons and Check Boxes to different groups of items such that the user can choose just one Radio Button from each group Radio Button controls are commonly used to represent program options. Radio Button Properties Property Action Name (rad ) Gets or Sets the name of the control. Appearance Represents whether the radio button looks like a traditional radio button or like a button. Back Color Represents the radio button's background color Checked Represents whether the radio button is checked Enabled Represents whether the user can interact with the radio button Fore Color Height Image Represents the color of the radio button text Represents the radio button height Represents the image that is displayed in the button Text Represents the radio button text Visible Represents whether the radio button is visible Width Represents the radio button's width Users sometimes have to make decisions that require selecting a combination of options from a set of alternatives. A Check Box appears as descriptive text next to a square. The essential difference between Radio Buttons and Check Boxes is that the radio Buttons have the restriction that the user selects only one option, whereas the Check Boxes do not. Check Box Properties Property Action Name ( chk) Gets or Sets the name of the control. Appearance Represents whether the check box looks like a traditional check box or like a button. Back Color Represents the check box background color Checked Represents whether or not the check box is checked or not ( True or False ) Enabled Represents whether the user can interact with the check box. Fore Color Represents the color of the check box text Height Represents the check box height Image Represents the image that is displayed in the button Text Visible Width Represents the check box text Represents whether the check box is visible Represents the check box width
22 The Group Box control Group Box control appears as a rectangle surrounding the controls it groups together. The group's Text property can be used to help identify the group to which the contents relate. Group Box Properties Property Name Enabled Flat Style Visible Action (grp) Gets or Sets the name of the control If the group box is not enabled ( value set to False ), than all the controls it contains also are not enabled Gets or sets the flat style appearance of the group box control. We have four choices for it : Flat, Popup, Standard ( default ), and System. If the group box is not visible ( value set to false ), then all the controls it contains also are not visible. - ٢٢ -
23 Questions 1) Multiple choice questions : If Then Else is a selection statement. a) single b) double c) triple d) None of the above. If Then is called a. Statement because it selects or ignores one action.. a) single-selection b) double-selection c) multiple-selection d) repetition. The operator returns False if the left operand is less than the right operand. a) = b) > c) d) All of the above. The if then Else selection statement ends with the keywords. a) End If b) End Else c) EndIf d) EndElse. The following shows a response only if the condition is equal to. If ( condition ) EndIf MsgBox( n is divisible d ) a) (n mod d) <> 0 b) (n \ d) = 0 c) (n mod d) = 0 d) (n\ d) <> 0 The property sets CheekBox's label. a) Label b) Text b) Checked d) Name The number of CheckBoxes that can be selected at once is equal to. a) 1 b) 2 c) 3 d) any number. - ٢٣ -
24 The condition (a AndAlso b) is True if. a) a is False and b is False b) a is False and is True c) A is True and b is False d) a is True and b is True. The condition (a Or Else b ) is False if. a) a is False and b is False b)a is True and b True c) a is True and b is False d) a is True and b is True. The condition (m Xor n ) is True if. a) m is True and n is True b) m is False and n is True c) m is True and n is False d) Both b and c. 2) Assume that a txtscore is a TextBox control and that the user entered the value 73.5 into the TextBox. Determine the action performed by the following code: 1 Dim score as Decimal 2 score = Decimal.Pares (textscore.text) 3 If score 90.0 Then 6 1b1Display. Text = Excellent 5 Else If score 75.0 Then. 6 lbldisplay. Text = Very Good 7 Else If score 60.0 Then 8 lbldisplay. Text = Good 9 Else If score 50.0 Then 10 lbldisplay. Text = Sufficient 11 Else 12 lbldisplay. Text = Insufficient 13 EndIf - ٢٤ -
25 Chapter 3: Repetition Statements Introduction All statements have been executed in order, from top to bottom, with two exceptions : the If, and Try / Catch. Now, we introduce the repetition statements, which are control statements that can repeat actions on a number of statements as long as a certain condition is True or False depending on the structure. The Do While..Loop Structure The top the loop Do while condition the loop continuation condition Statement 1 Statement Body of the Do While loop - Statement n Loop The bottom of the loop Each time the computer encounters Do While, it evaluates the condition If the condition is False, execution skips to the first statement following the reserved word Loop. If the condition is True, the computer executes theينفذ statements in the body of the loop from to bottom. 1- When Condition is False Do While condition Statement 1 Statement Body of the Do While loop - Statement n - ٢٥ -
26 Loop Statement x - ٢٦ -
27 2- When Condition is True Do While condition Statement 1 Statement Statement n Loop Statement x The For Next Loop Structure In contrast to the Do.. Loops, in which the number of repetitions of the loop body is unknown prior to processing. Note : The For Next Loop is used when we know the number of iterations of the loop in advance. L List Box Control One of the controls that are often associated with loops is the List Box. List Box appears as a rectangle that displays rows of text. Each row is an item that the user may select. The List Box properties Property Value Name (1 st.) Gets or sets the name of the control. Horizontal Scrollbar Gets or sets a Boolean value indicating whether a horizontal scroll is displayed in the control. Items Gets the items of the List Box. This property is itself an object that has its set of properties and methods. Selected Item Gets or sets the currently selected item in List Box. Sorted Gets or sets a Boolean value indicating whether the items in the List Box are sorted alphabetically regardless of the order they are entered. - ٢٧ -
28 List Box's Items property Method Add (text) Count Insert (index, text ) Remove (text) Remove At ( index ) Clear 0 Behavior Adds the text to the end of list of items Gets the number of items in the List Box Inserts the text at the index location indicated by index. The original item at that location and all items below it will be moved down to make room for the inserted item. Searches the items for an exact match of the text. It found that item is removed from the list and all items below it shift up one spot. Otherwise, nothing happens. Removes the item at the specific index value and all items below it shift up one spot. Removes all items from the List Box Questions 1- Multiple choice questions : 1.1 The body of a Do While Loop statement executes. a- Never b- at least once c- If its condition is True d- If its condition is False 1.2 Statements in the body of a Do Until Loop are executed repeatedly as long as the. remains False. a- Do loop condition b- loop continuation condition c- Until loop condition d- loop termination condition 1.3 The Statement executes until the loop continuation condition becomes False. a- Do Until.. Loop b- Do c- Do While d- Do While.. Loop 1.4 A. Is a variable that controls the number of times a number of statements will execute. a- repeater b- loop c- counter d- repetition control statement 1.5 Method.. deletes all the values in a List Box. a- Delete b- Clear c- Remove d- Destroy - ٢٨ -
29 1.6 Item's method adds an item to a List Box. a- Add b- Insert c- Include d- Append 2. Study the following code segment ( assume variable have been declared ) 1 Sum = 0 2 Count = 0 3 Do While ( x < 10 ) 4 Sum = sum + X 5 Count = count Loop 7 Average = sum / Count a- What is wrong with this code? b- Do steps to fix this code segment. Change x to COUNT 3. Find the error (s) in the following code. the loop should sum the numbers from 1 to 10 1 Dim x As Integer = 1 2 Dim Sum as Integer = 1 3 Do until x < = 10 4 Sum = sum + x 5 x = x Loop Change sign < to > 4. Consider the following code segment : 1 For I = To 10 Step X 2 Ms G Box (i) 3 Next Explain how loop will been have if : a. X is greater than 0 b. X is less than 0 c. X is equal to 0 Answer : a. will be executed b. not executed because ( X ) will be negative and the counter ( I ) well increase not decrease c. Will execute for only one time - ٢٩ -
30 5. Trace the following code segment, showing the value of each variable each time it changes : 1 X = For I = 0 To 7 Step 3 3 X = X* 2 4 Next Answer : I X X=4.5 For I = 0 to 7 step X = x * Next Convert the following for loop into a Do While Loop 1 For i = 1 To 10 2 Msg Box (i*i) 3 Next Answer : 1 Dim I as integer =1 2 Do while ( I < = 10 ) 3 MsgBox ( I * I ) 4 Loop 7. Describe the output from the following code segment 1 For i = 0 To 7 2 If (I / 2= 0 ) then 3 Msg Box (i+1) 4 Elself (I / 3= 0 ) then 5 Msg Box (i*i) 6 Elself (I / 5 = 0 ) then 7 Msg Box (2*i-1) 8 Else 9 Msg Box (i) 10 End If 11 Next Answer : The output will be as following : ( 1,1,2,3,4,5,6,7) - ٣٠ -
31 Chapter 4: Timers Introduction Events occur when the user takes an action like pressing a button or a radio Button. Sometimes we want to make events occur after some interval, without the user intervention. We can do that using Timer object Timer object : is an invisible stopwatch that gives you access to the system clock. The time interval for timer can be set using its Interval property. The time Interval can take the values 0 to 65,535 milliseconds, were one second is equal to 1,000 milliseconds. The timer Enable property has to be set to : 1- True to make the timer continuously running, (I) mean that the timer keeps firing every constant time period which is equal to its Interval property. 2- False to prevent the Tick event from occurring by setting the timer's Enabled property. The Enabled property default value is False, so you have to set it to True when you want to use the timer. The Date Time structure. Property Purpose Example Result Now Retrieve system date and time - ٣١ - X = Now 12/2/ :06:27PM Date Date Component x. Date 12/2/2008 Day Day of months: 1 31 x. Day 12 Day of Year Day of year : x. Day of Year 43 Hour Hour : 0 23 x. Hour 22 Minute Minute : 0 59 x. Minute 6 Second Second : 0 59 x. Second 27 Month Month ; 1= January x. Month 2 Add Days specified number of days later (or earlier ) x. Add Days (1) Add I day
32 Add Hours Specified number of hours later ( or earlier ) Add Minutes Specified a number of minutes later ( or earlier ) Note : x. Add Hours (5) x. Add Minutes ( 30 ) Add 5 hours x. Hour is equal to 22 because we are at 10o'clock P.M. Subtract 30 minutes Questions 1. Multiple choice questions : 1.1 Timer property Interval sets the rate a which Tick events occur in.. a- Seconds b- Milliseconds c- Nanosecond d- Microseconds 1.2 The.. Date structure retrieves your computer's date and time. a- Current Time b- Time c- Now d- Date Time 1.3 You can.. to a Date variable. a- Add days b- Add hours c- Subtract days d- All of the above 1.4 To subtract one day from Date variable X, assign the value returned by to X. a- X. Add Hours (-24) b- X. Subtract Days (1) c- X. Add Days (-1) d- All of the above 2. How long is an interval of 1500 seconds for a certain timer? 1500/1000 = 1.5 second 3. What fires a Timer's Tick event? To make enable property TRUE - ٣٢ -
33 THE COMPLETION OF THE BASIC EDUCATION CERTIFICATE Second Term Model 1 First Question: Put a tick ( ) in front of the true sentence and a cross (X) in front of the wrong sentence: 1- Variables of type Double, Single and Decimal allow storing fractional values, but with different degrees of precision. ( ) 2- When you declare a Variable, it is possible that the Variable Name begins with a number. ( ) 3-In (If Then ) statement, when the outcome of the condition is evaluated to be False then the statements following (Then) are executed. ( ) 4- The result of compound condition) X>=3 and Y<10) is True, if the two conditions are verified. ( ) 5-In (Do while Loop) statement, If the condition is evaluated to be True, execution of statements skips to the first statement following the reserved word (LOOP). ( ) 6- E prosecution is defined as sending a message by mistake to someone, you do not know ( ) Second Question: Choose the correct answer for each one of the following: 1- In For Next statement, the number of repetition in For X=1 to 8 step 3 is (a) 3 (b) 4 (c) 2 (d) 1 2- The property Interval for the (Timer) sets the rate at which the event occurs in (a) Second. (b) Minute. (c) Millisecond. (d) Hour. - ٣٣ -
34 3- We can stop the timer by giving the property the value false (a) Interval. (b) Enabled. (c) Modifiers (d) Tag 4- The Numeric Variable which takes integer numbers from 0 to 255 is.. (a) Integer. (b) String. (c) Byte. (d) Double. 5- One of the rules of naming the Variables or Constants in the program is: the variable name should start with.. (a) Number. (b) Any symbol. (c) Letter. (d) Space. Third Question: Rearrange the following steps in right order, to calculate the Sum of the odd numbers from 1 to 8: Loop Do While i <= 8 Dim i = 1, total As Integer Msgbox(total) total = total + i i = i + 2 Fourth Question: Choose from column b what is appropriate for coumn a: Column A Column B 1- DateTime (a) is used to repeat a group of command. 2- Const (b) is not equal. 3- For...Next (c) declaration of Constant. 4- Dim (d) equal. 5- Symbol <> is called (e) used with date and time (f) declaration of variable - ٣٤ -
35 First Question: THE COMPLETION OF THE BASIC EDUCATION CERTIFICATE Second Term Model 2 Put a tick ( ) in front of the true sentence and a cross (X) in front of the wrong sentence : 1-The result of executing the command MsgBox (5 + 3 ^ 2 / (8 mod 5)) gives 8 ( ) 2-Statements in the body of a (Do While.Loop), are executed only one time ( ) 3-(Timer) object can be used to execute a set of commands every constant period of time ( ) 4- You can use the (Text) property to write text inside the object (label1) or object (textbox1). ( ) Second Question: Complete the following statements from the words between brackets: 1- To delete all items from the object (listbox1), we use the method... ( Remove Clear Delete ) 2- To prevent the (Timer1) from running, you write the command " Timer1.enabled =.. " ( True False End ) 3- In (If Then Else ) statement, when the outcome of the condition is evaluated to be. then the statements following (Else) are executed ( True False Null ) 4- You can find out the date and time in the computer by executing the command MsgBox ( ) ( Now Time DateTime ) - ٣٥ -
36 Third Question: Use the figures and some of the words below to fill the spaces and complete the paragraph with true statements. CheckBox - RadioButton - second - first - TextBox The Design of Figure... is right where the tool... has been utilized to select one or more or none of the three foreign languages (English, French, and German) The design of Figure... is not right where the use of the tool... allow selecting only one language, from the three foreign languages. Fourth Question: Read the following code: Dim N, K, C As Integer C = 6 For N = 1 To 6 Step 3 K = K + N Next If N > C Then C = C + 1 End If Complete the following: 1- Value of the variable C is equal to Value of the variable N is equal to The result of the condition N> C is equal to Value of the variable K is equal to... - ٣٦ -
37 THE COMPLETION OF THE BASIC EDUCATION CERTIFICATE Second Term Model 3 First Question: State which of the following statements is (are) true or false 1- When the result of the conditional (Do while Loop) statement is True, then the statements inside the loop will be executed ( ) 2- The (For..Next ) statement continues to execute the statements as long as the starting value of the( iteration/repetition) is > 1 ( ) 3-The term "String" can be used as variable name to store string values assigned to (student names) ( ) 4-The (Timer) object can be used to execute a set of commands in constant time intervals ( ) 5- Anonymity is considered as form of Cyber bullying ( ) Second Question: Complete the following statements from the words between brackets. (Dim Const String - Single - Class Object) Khaled wants to write program codes to compute the total degrees of a student in all subjects, and 1-he uses numerical variable of type Single which is declared by the term ( ) 2-he uses also a variable type ( ) to store student name value. 3-he uses a variable of type ( ) to store the total degrees of the student in all subjects. - ٣٧ -
38 Third Question: Choose the suitable design from the two figures below: Fig (.). Fig ((1) ٢ ) Fig (2) Fourth Question: A) Read the following instructions Dim Age, Mark, Total As Single Age = 25.5 Mark = 90 If Age < 26 Then Age = 16 Mark=100 End If Total = Mark * 2 B) Execute the previous instructions,then choose the correct answers from the following: 1. The value of the variable "Age" is: a b -90 c The value of the variable "Mark" is: a 90 b-100 c The result of the condition Age < 26 : a 25.5 b- True c-false 4. The value of the variable "Total" is: a 200 b- 180 c- 190-٣٨ -
39 THE COMPLETION OF THE BASIC EDUCATION CERTIFICATE Second Term Model 4 First Question: Put a tick ( ) in front of the true sentence and a cross (X) in front of the wrong sentence: 1- The variable name "Spent_Money" is a valid name in terms of rules of naming variables. ( ) 2- The For Next Loop is used when we know in advance the number of iterations of the loop. ( ) 3-To clear the ListBox control from all items, the method Remove (text) is used.( ) 4-In a program, lines that begin with ('), are considered comments within the program code. ( ) 5-Variable of type Double is used to store integers only ( ) 6-Some forms of cyber bullying are the Outing of people through the dissemination of their private information. ( ) Second Question: Complete the following statements from the words between brackets: Is the range of values available for the numeric variable. (Accuracy - Range - The primary value of the variable) 2- Use a (Try / Catch) commands to... To detect errors and deal with it - to repeat the command a number of times - to repeat ) (the command once 3- The logical condition (M or N) will be wrong if... ( both N and M are false M is false,n is true both N and M are true ) 4- Statements written in the body of (Do While... Loop...) (are not implemented at all - are executed if the condition is True - are executed if the condition is False) 5- The Integer Division is expressed through (Div - \ - Mod ) 6- To prevent the occurrence of the event Tick so the Timer will be off, we set the property... a value False ( Interval - Enabled - Name ) - ٣٩ -
40 Third Question: 1- Write the scientific term for each phrase of the following statements: A: Method used to delete all items of the ListBox control is (...). B: Tool that allows programmers to divide a number of RadioButtons and CheckBoxes into different groups. (...). C: Tool that allows you to create or display a list of items (...). D: Tool that provide users with a range of alternatives to choose any of them at the same time. (..). 2- Read the following code: Dim X, Y, Z As Integer X = 2 Y = 3 Z = 4 MsgBox ( Y^X * X + Z * 3 ) And then type the result of the execution... : 2- Read the following code: Dim X, C As Integer X = 4 For C = 0 To 7 Step 3 X = X * 2 Next MsgBox ( X ) What is the value of x in the message box?... - ٤٠ -
41 THE COMPLETION OF THE BASIC EDUCATION CERTIFICATE Second Term Model 5 First Question: Put a tick ( ) in front of the true sentence and a cross (X) in front of the wrong sentence: 1- Variable of type Integer takes a range of integer numbers from 0 to 255. ( ) 2-The following names (Double, Single and Dim) can be used for naming Variables in program code. ( ) 3-If the variable A=20, variable B= 15 then the result of the condition A>=B is True. ( ) 4-In (Do while Loop) statement, execution of statements inside the loop are repeated until the condition in the Do While becomes False. ( ) 5-For the Variables of type Date, the subtraction of Days can be occurred. ( ) 6-You should remove immediately s sent from cyberbulling. ( ) Second Question: Complete the following statements from the words between brackets. (Dim Const String - Single - For Next) 1-To compute the total degrees of a student in all subjects, use numerical variable of type Single which is declared by the term ( ). 2-Also a variable type ( ) is used to store student name value. 3-Also a variable of type ( )is used to store the total degrees of the student in all subjects. 4-To declare constants, you can use the term ( ). 5-To repeat a set of commands, you can use ( ). - ٤١ -
42 Third Question: Rearrange the following steps in right order, to calculate the Sum of the odd numbers from 1 to 8: 1. total = total + i 2. Msgbox(total) 3. Next 4. For i = 1 To 8 Step 2 5. Dim i, total As Integer Fourth Question: Choose from column b what is appropriate for coumn a: Column A Column B 1- Count (A) is used to repeat a group of command. 2- Const (B) smaller than and equal. 3- Do While Loop (C) declaration of Constant. 4- Dim (D) greater than or equal. 5- Symbol >= is called (E) property used to identify the number of items in a Listbox tool (F) declaration of variable - ٤٢ -
Mr.Khaled Anwar ( )
The Rnd() function generates random numbers. Every time Rnd() is executed, it returns a different random fraction (greater than or equal to 0 and less than 1). If you end execution and run the program
More informationOverview About KBasic
Overview About KBasic The following chapter has been used from Wikipedia entry about BASIC and is licensed under the GNU Free Documentation License. Table of Contents Object-Oriented...2 Event-Driven...2
More informationVARIABLES. Aim Understanding how computer programs store values, and how they are accessed and used in computer programs.
Lesson 2 VARIABLES Aim Understanding how computer programs store values, and how they are accessed and used in computer programs. WHAT ARE VARIABLES? When you input data (i.e. information) into a computer
More informationAn overview about DroidBasic For Android
An overview about DroidBasic For Android from February 25, 2013 Contents An overview about DroidBasic For Android...1 Object-Oriented...2 Event-Driven...2 DroidBasic Framework...2 The Integrated Development
More informationBASIC ELEMENTS OF A COMPUTER PROGRAM
BASIC ELEMENTS OF A COMPUTER PROGRAM CSC128 FUNDAMENTALS OF COMPUTER PROBLEM SOLVING LOGO Contents 1 Identifier 2 3 Rules for naming and declaring data variables Basic data types 4 Arithmetic operators
More informationMicrosoft Excel 2010 Handout
Microsoft Excel 2010 Handout Excel is an electronic spreadsheet program you can use to enter and organize data, and perform a wide variety of number crunching tasks. Excel helps you organize and track
More informationReview: Exam 1. Your First C++ Program. Declaration Statements. Tells the compiler. Examples of declaration statements
Review: Exam 1 9/20/06 CS150 Introduction to Computer Science 1 1 Your First C++ Program 1 //*********************************************************** 2 // File name: hello.cpp 3 // Author: Shereen Khoja
More informationChapter 2 Using Data. Instructor s Manual Table of Contents. At a Glance. Overview. Objectives. Teaching Tips. Quick Quizzes. Class Discussion Topics
Java Programming, Sixth Edition 2-1 Chapter 2 Using Data At a Glance Instructor s Manual Table of Contents Overview Objectives Teaching Tips Quick Quizzes Class Discussion Topics Additional Projects Additional
More informationUNIT- 3 Introduction to C++
UNIT- 3 Introduction to C++ C++ Character Sets: Letters A-Z, a-z Digits 0-9 Special Symbols Space + - * / ^ \ ( ) [ ] =!= . $, ; : %! &? _ # = @ White Spaces Blank spaces, horizontal tab, carriage
More informationThe C++ Language. Arizona State University 1
The C++ Language CSE100 Principles of Programming with C++ (based off Chapter 2 slides by Pearson) Ryan Dougherty Arizona State University http://www.public.asu.edu/~redoughe/ Arizona State University
More informationOutline. Data and Operations. Data Types. Integral Types
Outline Data and Operations Data Types Arithmetic Operations Strings Variables Declaration Statements Named Constant Assignment Statements Intrinsic (Built-in) Functions Data and Operations Data and Operations
More informationFull file at
Java Programming, Fifth Edition 2-1 Chapter 2 Using Data within a Program At a Glance Instructor s Manual Table of Contents Overview Objectives Teaching Tips Quick Quizzes Class Discussion Topics Additional
More informationUnit 4. Lesson 4.1. Managing Data. Data types. Introduction. Data type. Visual Basic 2008 Data types
Managing Data Unit 4 Managing Data Introduction Lesson 4.1 Data types We come across many types of information and data in our daily life. For example, we need to handle data such as name, address, money,
More information2.1. Chapter 2: Parts of a C++ Program. Parts of a C++ Program. Introduction to C++ Parts of a C++ Program
Chapter 2: Introduction to C++ 2.1 Parts of a C++ Program Copyright 2009 Pearson Education, Inc. Publishing as Pearson Addison-Wesley 2-1 Parts of a C++ Program Parts of a C++ Program // sample C++ program
More informationYou will have mastered the material in this chapter when you can:
CHAPTER 6 Loop Structures OBJECTIVES You will have mastered the material in this chapter when you can: Add a MenuStrip object Use the InputBox function Display data using the ListBox object Understand
More informationDEPARTMENT OF MATHS, MJ COLLEGE
T. Y. B.Sc. Mathematics MTH- 356 (A) : Programming in C Unit 1 : Basic Concepts Syllabus : Introduction, Character set, C token, Keywords, Constants, Variables, Data types, Symbolic constants, Over flow,
More informationVBScript: Math Functions
C h a p t e r 3 VBScript: Math Functions In this chapter, you will learn how to use the following VBScript functions to World Class standards: 1. Writing Math Equations in VBScripts 2. Beginning a New
More informationProgramming Language 2 (PL2)
Programming Language 2 (PL2) 337.1.1 - Explain rules for constructing various variable types of language 337.1.2 Identify the use of arithmetical and logical operators 337.1.3 Explain the rules of language
More informationBEGINNING PROBLEM-SOLVING CONCEPTS FOR THE COMPUTER. Chapter 2
1 BEGINNING PROBLEM-SOLVING CONCEPTS FOR THE COMPUTER Chapter 2 2 3 Types of Problems that can be solved on computers : Computational problems involving some kind of mathematical processing Logical Problems
More informationProfessor: Sana Odeh Lecture 3 Python 3.1 Variables, Primitive Data Types & arithmetic operators
1 Professor: Sana Odeh odeh@courant.nyu.edu Lecture 3 Python 3.1 Variables, Primitive Data Types & arithmetic operators Review What s wrong with this line of code? print( He said Hello ) What s wrong with
More informationChapter 2: Introduction to C++
Chapter 2: Introduction to C++ Copyright 2010 Pearson Education, Inc. Copyright Publishing as 2010 Pearson Pearson Addison-Wesley Education, Inc. Publishing as Pearson Addison-Wesley 2.1 Parts of a C++
More informationIntroduction to Visual Basic and Visual C++ Arithmetic Expression. Arithmetic Expression. Using Arithmetic Expression. Lesson 4.
Introduction to Visual Basic and Visual C++ Arithmetic Expression Lesson 4 Calculation I154-1-A A @ Peter Lo 2010 1 I154-1-A A @ Peter Lo 2010 2 Arithmetic Expression Using Arithmetic Expression Calculations
More informationChapter 2: Special Characters. Parts of a C++ Program. Introduction to C++ Displays output on the computer screen
Chapter 2: Introduction to C++ 2.1 Parts of a C++ Program Copyright 2009 Pearson Education, Inc. Copyright 2009 Publishing Pearson as Pearson Education, Addison-Wesley Inc. Publishing as Pearson Addison-Wesley
More informationIn this section you will learn some simple data entry, editing, formatting techniques and some simple formulae. Contents
In this section you will learn some simple data entry, editing, formatting techniques and some simple formulae. Contents Section Topic Sub-topic Pages Section 2 Spreadsheets Layout and Design S2: 2 3 Formulae
More informationChapter 2 Using Data. Instructor s Manual Table of Contents. At a Glance. A Guide to this Instructor s Manual:
Java Programming, Eighth Edition 2-1 Chapter 2 Using Data A Guide to this Instructor s Manual: We have designed this Instructor s Manual to supplement and enhance your teaching experience through classroom
More informationFundamental of Programming (C)
Borrowed from lecturer notes by Omid Jafarinezhad Fundamental of Programming (C) Lecturer: Vahid Khodabakhshi Lecture 3 Constants, Variables, Data Types, And Operations Department of Computer Engineering
More information\n is used in a string to indicate the newline character. An expression produces data. The simplest expression
Chapter 1 Summary Comments are indicated by a hash sign # (also known as the pound or number sign). Text to the right of the hash sign is ignored. (But, hash loses its special meaning if it is part of
More informationegrapher Language Reference Manual
egrapher Language Reference Manual Long Long: ll3078@columbia.edu Xinli Jia: xj2191@columbia.edu Jiefu Ying: jy2799@columbia.edu Linnan Wang: lw2645@columbia.edu Darren Chen: dsc2155@columbia.edu 1. Introduction
More information1. Introduction to Microsoft Excel
1. Introduction to Microsoft Excel A spreadsheet is an online version of an accountant's worksheet, which can automatically do most of the calculating for you. You can do budgets, analyze data, or generate
More informationProgram Fundamentals
Program Fundamentals /* HelloWorld.java * The classic Hello, world! program */ class HelloWorld { public static void main (String[ ] args) { System.out.println( Hello, world! ); } } /* HelloWorld.java
More informationContents. Jairo Pava COMS W4115 June 28, 2013 LEARN: Language Reference Manual
Jairo Pava COMS W4115 June 28, 2013 LEARN: Language Reference Manual Contents 1 Introduction...2 2 Lexical Conventions...2 3 Types...3 4 Syntax...3 5 Expressions...4 6 Declarations...8 7 Statements...9
More informationFull file at
Java Programming: From Problem Analysis to Program Design, 3 rd Edition 2-1 Chapter 2 Basic Elements of Java At a Glance Instructor s Manual Table of Contents Overview Objectives s Quick Quizzes Class
More informationC++ Programming: From Problem Analysis to Program Design, Third Edition
C++ Programming: From Problem Analysis to Program Design, Third Edition Chapter 2: Basic Elements of C++ Objectives (continued) Become familiar with the use of increment and decrement operators Examine
More informationLanguage Basics. /* The NUMBER GAME - User tries to guess a number between 1 and 10 */ /* Generate a random number between 1 and 10 */
Overview Language Basics This chapter describes the basic elements of Rexx. It discusses the simple components that make up the language. These include script structure, elements of the language, operators,
More informationLanguage Fundamentals
Language Fundamentals VBA Concepts Sept. 2013 CEE 3804 Faculty Language Fundamentals 1. Statements 2. Data Types 3. Variables and Constants 4. Functions 5. Subroutines Data Types 1. Numeric Integer Long
More informationMicrosoft Visual Basic 2005: Reloaded
Microsoft Visual Basic 2005: Reloaded Second Edition Chapter 3 Variables, Constants, Methods, and Calculations Objectives After studying this chapter, you should be able to: Declare variables and named
More informationComputer Net Revision
First:In the following Form window, if it is required to store entries from the user in variables. Define the corresponding Data Type for each input. 1. 2. 3. 4. 1 2 3 4 1- Less number of bytes means more
More informationChapter 2. Designing a Program. Input, Processing, and Output Fall 2016, CSUS. Chapter 2.1
Chapter 2 Input, Processing, and Output Fall 2016, CSUS Designing a Program Chapter 2.1 1 Algorithms They are the logic on how to do something how to compute the value of Pi how to delete a file how to
More information2 nd Week Lecture Notes
2 nd Week Lecture Notes Scope of variables All the variables that we intend to use in a program must have been declared with its type specifier in an earlier point in the code, like we did in the previous
More informationIntroduction to C# Applications
1 2 3 Introduction to C# Applications OBJECTIVES To write simple C# applications To write statements that input and output data to the screen. To declare and use data of various types. To write decision-making
More informationVB FUNCTIONS AND OPERATORS
VB FUNCTIONS AND OPERATORS In der to compute inputs from users and generate results, we need to use various mathematical operats. In Visual Basic, other than the addition (+) and subtraction (-), the symbols
More informationMicrosoft Visual Basic 2015: Reloaded
Microsoft Visual Basic 2015: Reloaded Sixth Edition Chapter Three Memory Locations and Calculations Objectives After studying this chapter, you should be able to: Declare variables and named constants
More informationChapter 3: Operators, Expressions and Type Conversion
101 Chapter 3 Operators, Expressions and Type Conversion Chapter 3: Operators, Expressions and Type Conversion Objectives To use basic arithmetic operators. To use increment and decrement operators. To
More informationSTATISTICAL TECHNIQUES. Interpreting Basic Statistical Values
STATISTICAL TECHNIQUES Interpreting Basic Statistical Values INTERPRETING BASIC STATISTICAL VALUES Sample representative How would one represent the average or typical piece of information from a given
More informationIntroduction to Data Entry and Data Types
212 Chapter 4 Variables and Arithmetic Operations STEP 1 With the Toolbox visible (see Figure 4-21), click the Toolbox Close button. The Toolbox closes and the work area expands in size.to reshow the Toolbox
More informationJAVA Programming Fundamentals
Chapter 4 JAVA Programming Fundamentals By: Deepak Bhinde PGT Comp.Sc. JAVA character set Character set is a set of valid characters that a language can recognize. It may be any letter, digit or any symbol
More informationVariable A variable is a value that can change during the execution of a program.
Declare and use variables and constants Variable A variable is a value that can change during the execution of a program. Constant A constant is a value that is set when the program initializes and does
More information3. Types of Algorithmic and Program Instructions
3. Types of Algorithmic and Program Instructions Objectives 1. Introduce programming language concepts of variables, constants and their data types 2. Introduce types of algorithmic and program instructions
More informationLecture 2 FORTRAN Basics. Lubna Ahmed
Lecture 2 FORTRAN Basics Lubna Ahmed 1 Fortran basics Data types Constants Variables Identifiers Arithmetic expression Intrinsic functions Input-output 2 Program layout PROGRAM program name IMPLICIT NONE
More informationUnit 3. Constants and Expressions
1 Unit 3 Constants and Expressions 2 Review C Integer Data Types Integer Types (signed by default unsigned with optional leading keyword) C Type Bytes Bits Signed Range Unsigned Range [unsigned] char 1
More informationAgenda & Reading. VB.NET Programming. Data Types. COMPSCI 280 S1 Applications Programming. Programming Fundamentals
Agenda & Reading COMPSCI 80 S Applications Programming Programming Fundamentals Data s Agenda: Data s Value s Reference s Constants Literals Enumerations Conversions Implicitly Explicitly Boxing and unboxing
More informationUnit 3. Operators. School of Science and Technology INTRODUCTION
INTRODUCTION Operators Unit 3 In the previous units (unit 1 and 2) you have learned about the basics of computer programming, different data types, constants, keywords and basic structure of a C program.
More informationThese are reserved words of the C language. For example int, float, if, else, for, while etc.
Tokens in C Keywords These are reserved words of the C language. For example int, float, if, else, for, while etc. Identifiers An Identifier is a sequence of letters and digits, but must start with a letter.
More informationChapter 3 Problem Solving and the Computer
Chapter 3 Problem Solving and the Computer An algorithm is a step-by-step operations that the CPU must execute in order to solve a problem, or to perform that task. A program is the specification of an
More information1. What is the minimum number of bits needed to store a single piece of data representing: a. An integer between 0 and 100?
1 CS 105 Review Questions Most of these questions appeared on past exams. 1. What is the minimum number of bits needed to store a single piece of data representing: a. An integer between 0 and 100? b.
More informationExcel Level 1
Excel 2016 - Level 1 Tell Me Assistant The Tell Me Assistant, which is new to all Office 2016 applications, allows users to search words, or phrases, about what they want to do in Excel. The Tell Me Assistant
More informationVisual C# Instructor s Manual Table of Contents
Visual C# 2005 2-1 Chapter 2 Using Data At a Glance Instructor s Manual Table of Contents Overview Objectives s Quick Quizzes Class Discussion Topics Additional Projects Additional Resources Key Terms
More informationIntroduction to the C++ Programming Language
LESSON SET 2 Introduction to the C++ Programming Language OBJECTIVES FOR STUDENT Lesson 2A: 1. To learn the basic components of a C++ program 2. To gain a basic knowledge of how memory is used in programming
More informationFundamentals. Fundamentals. Fundamentals. We build up instructions from three types of materials
Fundamentals We build up instructions from three types of materials Constants Expressions Fundamentals Constants are just that, they are values that don t change as our macros are executing Fundamentals
More informationChapter 1 Summary. Chapter 2 Summary. end of a string, in which case the string can span multiple lines.
Chapter 1 Summary Comments are indicated by a hash sign # (also known as the pound or number sign). Text to the right of the hash sign is ignored. (But, hash loses its special meaning if it is part of
More informationLesson Skill Matrix Skill Exam Objective Objective Number
Lesson 6 Page 1 Creating Tables Lesson Skill Matrix Skill Exam Objective Objective Number Creating a Table Create a table by specifying rows and columns. 3.1.3 Formatting a Table Apply table styles. 3.1.4
More informationSkill Exam Objective Objective Number
Creating Tables 6 LESSON SKILL MATRIX Skill Exam Objective Objective Number Creating a Table Create a table by specifying rows and columns. 3.1.3 Formatting a Table Apply table styles. 3.1.4 Managing Tables
More informationSUM - This says to add together cells F28 through F35. Notice that it will show your result is
COUNTA - The COUNTA function will examine a set of cells and tell you how many cells are not empty. In this example, Excel analyzed 19 cells and found that only 18 were not empty. COUNTBLANK - The COUNTBLANK
More informationMATVEC: MATRIX-VECTOR COMPUTATION LANGUAGE REFERENCE MANUAL. John C. Murphy jcm2105 Programming Languages and Translators Professor Stephen Edwards
MATVEC: MATRIX-VECTOR COMPUTATION LANGUAGE REFERENCE MANUAL John C. Murphy jcm2105 Programming Languages and Translators Professor Stephen Edwards Language Reference Manual Introduction The purpose of
More informationBITG 1233: Introduction to C++
BITG 1233: Introduction to C++ 1 Learning Outcomes At the end of this lecture, you should be able to: Identify basic structure of C++ program (pg 3) Describe the concepts of : Character set. (pg 11) Token
More informationAssoc. Prof. Dr. Marenglen Biba. (C) 2010 Pearson Education, Inc. All rights reserved.
Assoc. Prof. Dr. Marenglen Biba (C) 2010 Pearson Education, Inc. All for repetition statement do while repetition statement switch multiple-selection statement break statement continue statement Logical
More informationData and Variables. Data Types Expressions. String Concatenation Variables Declaration Assignment Shorthand operators. Operators Precedence
Data and Variables Data Types Expressions Operators Precedence String Concatenation Variables Declaration Assignment Shorthand operators Review class All code in a java file is written in a class public
More informationThe Mathcad Workspace 7
For information on system requirements and how to install Mathcad on your computer, refer to Chapter 1, Welcome to Mathcad. When you start Mathcad, you ll see a window like that shown in Figure 2-1. By
More informationQuick Reference Guide
SOFTWARE AND HARDWARE SOLUTIONS FOR THE EMBEDDED WORLD mikroelektronika Development tools - Books - Compilers Quick Reference Quick Reference Guide with EXAMPLES for Basic language This reference guide
More informationUNIT 1. Introduction to Microsoft.NET framework and Basics of VB.Net
UNIT 1 Introduction to Microsoft.NET framework and Basics of VB.Net 1 SYLLABUS 1.1 Overview of Microsoft.NET Framework 1.2 The.NET Framework components 1.3 The Common Language Runtime (CLR) Environment
More informationArithmetic Expressions in C
Arithmetic Expressions in C Arithmetic Expressions consist of numeric literals, arithmetic operators, and numeric variables. They simplify to a single value, when evaluated. Here is an example of an arithmetic
More informationNOTES: Variables & Constants (module 10)
Computer Science 110 NAME: NOTES: Variables & Constants (module 10) Introduction to Variables A variable is like a container. Like any other container, its purpose is to temporarily hold or store something.
More informationC How to Program, 6/e by Pearson Education, Inc. All Rights Reserved.
C How to Program, 6/e 1992-2010 by Pearson Education, Inc. An important part of the solution to any problem is the presentation of the results. In this chapter, we discuss in depth the formatting features
More informationTopic 2: Introduction to Programming
Topic 2: Introduction to Programming 1 Textbook Strongly Recommended Exercises The Python Workbook: 12, 13, 23, and 28 Recommended Exercises The Python Workbook: 5, 7, 15, 21, 22 and 31 Recommended Reading
More informationFundamentals of Programming
Fundamentals of Programming Lecture 3 - Constants, Variables, Data Types, And Operations Lecturer : Ebrahim Jahandar Borrowed from lecturer notes by Omid Jafarinezhad Outline C Program Data types Variables
More informationLaboratory 0 Week 0 Advanced Structured Programming An Introduction to Visual Studio and C++
Laboratory 0 Week 0 Advanced Structured Programming An Introduction to Visual Studio and C++ 0.1 Introduction This is a session to familiarize working with the Visual Studio development environment. It
More information9. Elementary Algebraic and Transcendental Scalar Functions
Scalar Functions Summary. Introduction 2. Constants 2a. Numeric Constants 2b. Character Constants 2c. Symbol Constants 2d. Nested Constants 3. Scalar Functions 4. Arithmetic Scalar Functions 5. Operators
More informationExpressions and Data Types CSC 121 Spring 2015 Howard Rosenthal
Expressions and Data Types CSC 121 Spring 2015 Howard Rosenthal Lesson Goals Understand the basic constructs of a Java Program Understand how to use basic identifiers Understand simple Java data types
More informationAccelerating Information Technology Innovation
Accelerating Information Technology Innovation http://aiti.mit.edu Cali, Colombia Summer 2012 Lesson 02 Variables and Operators Agenda Variables Types Naming Assignment Data Types Type casting Operators
More informationSection 1.1 Definitions and Properties
Section 1.1 Definitions and Properties Objectives In this section, you will learn to: To successfully complete this section, you need to understand: Abbreviate repeated addition using Exponents and Square
More informationC++ PROGRAMMING. For Industrial And Electrical Engineering Instructor: Ruba A. Salamh
C++ PROGRAMMING For Industrial And Electrical Engineering Instructor: Ruba A. Salamh CHAPTER TWO: Fundamental Data Types Chapter Goals In this chapter, you will learn how to work with numbers and text,
More informationComputer System and programming in C
1 Basic Data Types Integral Types Integers are stored in various sizes. They can be signed or unsigned. Example Suppose an integer is represented by a byte (8 bits). Leftmost bit is sign bit. If the sign
More informationChapter 2. C++ Basics. Copyright 2014 Pearson Addison-Wesley. All rights reserved.
Chapter 2 C++ Basics 1 Overview 2.1 Variables and Assignments 2.2 Input and Output 2.3 Data Types and Expressions 2.4 Simple Flow of Control 2.5 Program Style Slide 2-3 2.1 Variables and Assignments 2
More informationOverview of C. Basic Data Types Constants Variables Identifiers Keywords Basic I/O
Overview of C Basic Data Types Constants Variables Identifiers Keywords Basic I/O NOTE: There are six classes of tokens: identifiers, keywords, constants, string literals, operators, and other separators.
More informationDATA WAREHOUSE BASICS
DATA WAREHOUSE BASICS A Software Overview using the Retail Golf Model with version 9 NOTE: This course material was developed using Hummingbird version 9 with Windows XP. There will be navigational differences
More informationDarshan Institute of Engineering & Technology for Diploma Studies
Overview of Microsoft.Net Framework: The Dot Net or.net is a technology that is an outcome of Microsoft s new strategy to develop window based robust applications and rich web applications and to keep
More informationCHAPTER 3 BASIC INSTRUCTION OF C++
CHAPTER 3 BASIC INSTRUCTION OF C++ MOHD HATTA BIN HJ MOHAMED ALI Computer programming (BFC 20802) Subtopics 2 Parts of a C++ Program Classes and Objects The #include Directive Variables and Literals Identifiers
More informationIT 374 C# and Applications/ IT695 C# Data Structures
IT 374 C# and Applications/ IT695 C# Data Structures Module 2.1: Introduction to C# App Programming Xianrong (Shawn) Zheng Spring 2017 1 Outline Introduction Creating a Simple App String Interpolation
More informationWhat we will do today Explain and look at examples of. Programs that examine data. Data types. Topic 4. variables. expressions. assignment statements
Topic 4 Variables Once a programmer has understood the use of variables, he has understood the essence of programming -Edsger Dijkstra What we will do today Explain and look at examples of primitive data
More informationThere are four numeric types: 1. Integers, represented as a 32 bit (or longer) quantity. Digits sequences (possibly) signed are integer literals:
Numeric Types There are four numeric types: 1. Integers, represented as a 32 bit (or longer) quantity. Digits sequences (possibly) signed are integer literals: 1-123 +456 2. Long integers, of unlimited
More informationChapter Overview. C++ Basics. Variables and Assignments. Variables and Assignments. Keywords. Identifiers. 2.1 Variables and Assignments
Chapter 2 C++ Basics Overview 2.1 Variables and Assignments 2.2 Input and Output 2.3 Data Types and Expressions 2.4 Simple Flow of Control 2.5 Program Style Copyright 2011 Pearson Addison-Wesley. All rights
More informationCSc 10200! Introduction to Computing. Lecture 2-3 Edgardo Molina Fall 2013 City College of New York
CSc 10200! Introduction to Computing Lecture 2-3 Edgardo Molina Fall 2013 City College of New York 1 C++ for Engineers and Scientists Third Edition Chapter 2 Problem Solving Using C++ 2 Objectives In this
More informationUNIT 3 OPERATORS. [Marks- 12]
1 UNIT 3 OPERATORS [Marks- 12] SYLLABUS 2 INTRODUCTION C supports a rich set of operators such as +, -, *,,
More informationComputer Programming, I. Laboratory Manual. Experiment #3. Selections
Think Twice Code Once The Islamic University of Gaza Engineering Faculty Department of Computer Engineering Fall 2017 ECOM 2005 Khaleel I. Shaheen Computer Programming, I Laboratory Manual Experiment #3
More informationFeatures of C. Portable Procedural / Modular Structured Language Statically typed Middle level language
1 History C is a general-purpose, high-level language that was originally developed by Dennis M. Ritchie to develop the UNIX operating system at Bell Labs. C was originally first implemented on the DEC
More informationFull file at Excel Chapter 2 - Formulas, Functions, Formatting, and Web Queries
Excel Chapter 2 - Formulas, Functions, Formatting, and Web Queries MULTIPLE CHOICE 1. To start a new line in a cell, press after each line, except for the last line, which is completed by clicking the
More informationChapter 2: Using Data
Chapter 2: Using Data TRUE/FALSE 1. A variable can hold more than one value at a time. F PTS: 1 REF: 52 2. The legal integer values are -2 31 through 2 31-1. These are the highest and lowest values that
More informationLearning Language. Reference Manual. George Liao (gkl2104) Joseanibal Colon Ramos (jc2373) Stephen Robinson (sar2120) Huabiao Xu(hx2104)
Learning Language Reference Manual 1 George Liao (gkl2104) Joseanibal Colon Ramos (jc2373) Stephen Robinson (sar2120) Huabiao Xu(hx2104) A. Introduction Learning Language is a programming language designed
More informationThe Warhol Language Reference Manual
The Warhol Language Reference Manual Martina Atabong maa2247 Charvinia Neblett cdn2118 Samuel Nnodim son2105 Catherine Wes ciw2109 Sarina Xie sx2166 Introduction Warhol is a functional and imperative programming
More informationBuilding Java Programs. Chapter 2: Primitive Data and Definite Loops
Building Java Programs Chapter 2: Primitive Data and Definite Loops Copyright 2008 2006 by Pearson Education 1 Lecture outline data concepts Primitive types: int, double, char (for now) Expressions: operators,
More information