(Subroutines in Visual Basic)

Size: px
Start display at page:

Download "(Subroutines in Visual Basic)"

Transcription

1 Ch 7 Procedures (Subroutines in Visual Basic) Visual Basic Procedures Structured Programs To simplify writing complex programs, most Programmers (Designers/Developers) choose to split the problem into simpler smaller tasks (modules). They then solve each small task before linking the 'modules' together as a complete program. The modules, being smaller and simpler, are easier to design, write and test. The final program is made by combining individually tested modules, so that final checking consists of making sure that the modules work together as intended. Advantages to structuring a program in this way are that it aids readability when designing or amending. It also reduces the size of the program (a module is written once and can be used in several parts of a program and even included in other programs). Modules /Subroutines/Procedures A module is also called a subroutine or a procedure. All BASIC code for forms and control objects are contained in modules, but (as explained above) a complex task can be simplified by breaking it down into smaller steps and tackling each step as a separate module. A subroutine is created in BASIC as follows: (looks similar to a Form or object event procedure) SUB subname (parameter,...) END SUB : : : statements : : : subname parameter - the name of the subroutine. Used to call the subroutine from the main program. - one or more variables passed to the subroutine from the main program. ByVal The value of the variable is passed to the procedure. This mean that the value in the main program is not changed. ByRef The memory location is passed to the procedure. This means that the value in the main program IS changed. Ch7-Procedures WED Section 7-1

2 Example This is a trivial problem but serves to demonstrate the use of a subroutine within an event procedure Sub Main() Dim FirstNum As Integer Dim SecondNum As Integer Console.WriteLine("Test Max()") Console.Write("Enter First Number :") FirstNum = Console.ReadLine() Console.Write("Enter Second Number :") SecondNum = Console.ReadLine() Max (FirstNum, SecondNum) Console.ReadKey() The Main program Calls the procedure Max with the two numbers as the parameters Sub Max(ByVal n1 As Integer, ByVal n2 As Integer) If N1 > n2 Then Console.WriteLine("{0} is greater.", n1) Else Console.WriteLine("{0} is greater.", n2) End If The procedure Receives FirstNum as n1 & SecondNum as n2 Program Run Test Max ( ) Enter First Number : 10 Enter Second Number : 5 10 is greater The program accepts two numbers entered from the user and sends them to the Subroutine Max() in its parameters. Max() then decides which number is greater and displays it on screen. Note that Max receives its parameters ByVal (see previous page) Also the received variables do not have to have the same name as their name in the main program. This is a simple example of a Procedure but that s how it works folks! Exercise 7.1 1) Create the program above & test it. 2) Add a new function called Min to display the lowest value. 3) What if the two values are equal? Ch7-Procedures WED Section 7-2

3 An Example using ByRef. In this example the parameters are passed ByRef. The procedure SWAP receives two variables in its parameter and swaps them into order (Highest & lowest). When the main program writes the variables the swap routine has put them into order. Sub Main() Dim FirstNum As Integer Dim SecondNum As Integer Console.WriteLine("Test Swap()") Console.Write("Enter First Number :") FirstNum = Console.ReadLine() Console.Write("Enter Second Number :") SecondNum = Console.ReadLine() Swap(FirstNum, SecondNum) Console.WriteLine("Highest value is {0}", FirstNum) Console.WriteLine("Lowest value is {0}", SecondNum) Console.ReadKey() Sub Swap(ByRef n1 As Integer, ByRef n2 As Integer) Dim temp As Integer If n1 < n2 Then temp = n1 n1 = n2 n2 = temp End If The parameters are received as ByRef so the changes made to the variables will be taken back into the main program. Temp is a local variable Program Run: Test Swap() Enter First Number : 10 Enter Second Number : 5 Highest value is 10 Lowest value is 5 Exercise 7.2 1) Create the program above and test it 2) Change the data types to string and get the swap() procedure to sort into alphabetical order. Ch7-Procedures WED Section 7-3

4 Further Example As a further example consider the following procedure that determines the grade awarded to a student. The procedure has two parameters: Mark is declared as Integer to receive the students mark (ByVal) Grade is declared as Char to return the grade (ByRef) SUB CalcGrade (ByVal Mark as Integer, ByRef Grade as Char) IF Mark > 75 THEN Grade = "Dist" ELSEIF Mark > 60 THEN Grade = "Merit" ELSEIF Mark > 45 THEN Grade = "Pass" ELSEIF Mark > 35 THEN Grade = "Ref" ELSE Grade = "Fail" END SUB A series of IF...THEN statements test the student Mark and set the grade accordingly. When the procedure has completed the appropriate grade is returned through the parameter to the main program. The call instruction could take the form: CalcGrade (TotalMark, Grade) Exercise 7.3 1) Write a program that uses the CalcGrade procedure to determine the grade for a student. Ch7-Procedures WED Section 7-4

5 Global & Local Variables A Procedure can be thought of as a small program in its own right. It creates a memory block of its own and (as well as the parameters it receives) may create its own variables if needed. The variables declared (DIM) within a procedure are called local variables and are used in that procedure only (i.e. local to that procedure). Variables declared in the main program are called global variables and can be used within the main program and any procedure or function within the module. It is not advisable to change a global variable within a procedure or function unless the variable has been passed as a parameter using ByRef. Scope Scope defines the visibility of a variable. Variables can have scope ranging from global where any procedure in the application can access the variable to local used only in a single procedure. There are three types of scope for variables in Visual Basic: Global Scope -Global variables are in scope anywhere in your application. Module Scope -Module level variables are in scope anywhere within the module where they are declared. Local Scope -Local variables are only in scope within the procedure where they are declared. Variables may be declared as follows: Term Public Private Visibility Anywhere in or outside of a project Only in the block where defined Ch7-Procedures WED Section 7-5

Part 4 - Procedures and Functions

Part 4 - Procedures and Functions Part 4 - Procedures and Functions Problem Solving Methodology... 2 Top Down Design... 2 Procedures and Functions... 5 Sub Procedures... 6 Sending Parameters to a Sub Procedure... 7 Pass by Value... 8 Pass

More information

Function: function procedures and sub procedures share the same characteristics, with

Function: function procedures and sub procedures share the same characteristics, with Function: function procedures and sub procedures share the same characteristics, with one important difference- function procedures return a value (e.g., give a value back) to the caller, whereas sub procedures

More information

Chapter 6 Sub Procedures

Chapter 6 Sub Procedures Sub Procedures A set of statements that perform a specific task. Divide a program into smaller, more manageable blocks of code. An event procedure is written for a specific object event, while a sub procedure

More information

Level 3 Computing Year 2 Lecturer: Phil Smith

Level 3 Computing Year 2 Lecturer: Phil Smith Level 3 Computing Year 2 Lecturer: Phil Smith Previously We started to build a GUI program using visual studio 2010 and vb.net. We have a form designed. We have started to write the code to provided the

More information

Sub Programs. To Solve a Problem, First Make It Simpler

Sub Programs. To Solve a Problem, First Make It Simpler Sub Programs To Solve a Problem, First Make It Simpler Top Down Design Top Down Design Start with overall goal. Break Goal into Sub Goals Break Sub Goals into Sub Sub Goals Until the Sub-Sub Sub-Sub Sub-Sub

More information

Lab Sheet 4.doc. Visual Basic. Lab Sheet 4: Non Object-Oriented Programming Practice

Lab Sheet 4.doc. Visual Basic. Lab Sheet 4: Non Object-Oriented Programming Practice Visual Basic Lab Sheet 4: Non Object-Oriented Programming Practice This lab sheet builds on the basic programming you have done so far, bringing elements of file handling, data structuring and information

More information

VB Net Debugging (Console)

VB Net Debugging (Console) VB Net Debugging (Console) Introduction A bug is some sort of error in the code which can prevent your program from running properly. When. you write a substantial program always assume that it contains

More information

String sequence of characters string Unicode Characters immutable they cannot be changed after they have been created.

String sequence of characters string Unicode Characters immutable they cannot be changed after they have been created. String A string is basically a sequence of characters A string in C# is an object of type String The string type represents a string of Unicode Characters. String objects are immutable that is they cannot

More information

Language Fundamentals

Language 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 information

MIS 216 SPRING 2018 PROJECT 4

MIS 216 SPRING 2018 PROJECT 4 MIS 216 SPRING 2018 PROJECT 4 Subs / Functions Arrays / Classes 1. Start a new project a. Create a folder on your desktop name it yourinitialsproject3 as in tnjproject3. b. FILE NEW PROJECT c. Change the

More information

Duhok Polytechnic University Amedi Technical Institute/ IT Dept. Halkawt Rajab Hussain

Duhok Polytechnic University Amedi Technical Institute/ IT Dept. Halkawt Rajab Hussain Duhok Polytechnic University Amedi Technical Institute/ IT Dept. By Halkawt Rajab Hussain 2016-04-02 Objects and classes: Basics of object and class in C#. Private and public members and protected. Static

More information

Chapter 2.5 Writing maintainable programs

Chapter 2.5 Writing maintainable programs Chapter 2.5 Writing maintainable programs Good program writing techniques Maintenance is the updating of a program after it has been released. Maintenance will be helped when the programmer uses good programming

More information

Introduction to C# Applications

Introduction 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 information

Programming with Visual Studio Higher (v. 2013)

Programming with Visual Studio Higher (v. 2013) Programming with Visual Studio Higher (v. 2013) Contents/Requirements Checklist Multiple selection: using ifs & case While Loops Using arrays Filling arrays Displaying array contents Types of variables:

More information

Introduction to. Copyright HKTA Tang Hin Memorial Secondary School 2016

Introduction to. Copyright HKTA Tang Hin Memorial Secondary School 2016 Introduction to 2 VISUAL BASIC 2016 edition Copyright HKTA Tang Hin Memorial Secondary School 2016 Table of Contents. Chapter....... 1.... More..... on.. Operators........................................

More information

Software Development Techniques. 26 November Marking Scheme

Software Development Techniques. 26 November Marking Scheme Software Development Techniques 26 November 2015 Marking Scheme This marking scheme has been prepared as a guide only to markers. This is not a set of model answers, or the exclusive answers to the questions,

More information

Understanding the problem

Understanding the problem 2.1.1 Problem solving and design An algorithm is a plan, a logical step-by-step process for solving a problem. Algorithms are normally written as a flowchart or in pseudocode. The key to any problem-solving

More information

MARK SCHEME for the October/November 2013 series 9691 COMPUTING. 9691/23 Paper 2 (Written Paper), maximum raw mark 75

MARK SCHEME for the October/November 2013 series 9691 COMPUTING. 9691/23 Paper 2 (Written Paper), maximum raw mark 75 CAMBRIDGE INTERNATIONAL EXAMINATIONS GCE Advanced Subsidiary Level and GCE Advanced Level MARK SCHEME for the October/November 2013 series 9691 COMPUTING 9691/23 Paper 2 (Written Paper), maximum raw mark

More information

Arrays. Storing Multiple Values

Arrays. Storing Multiple Values Arrays Storing Multiple Values Motels If you have a room in a motel and they give you room 5, which room is it? 1 2 3 4 5 6 Hotels If you have room 1541 in the Deluxe Ritz Hilton, which floor would you

More information

Programmers should write code that is self-documenting and split into small sections.

Programmers should write code that is self-documenting and split into small sections. Writing Programs What are good program writing techniques? Programmers should write code that is self-documenting and split into small sections. Specifically, the programmers should: use meaningful identifier

More information

Darshan Institute of Engineering & Technology for Diploma Studies

Darshan Institute of Engineering & Technology for Diploma Studies Dialog Box: There are many built-in dialog boxes to be used in Windows forms for various tasks like opening and saving files, printing a page, providing choices for colors, fonts, page setup, etc., to

More information

VBA Handout. References, tutorials, books. Code basics. Conditional statements. Dim myvar As <Type >

VBA Handout. References, tutorials, books. Code basics. Conditional statements. Dim myvar As <Type > VBA Handout References, tutorials, books Excel and VBA tutorials Excel VBA Made Easy (Book) Excel 2013 Power Programming with VBA (online library reference) VBA for Modelers (Book on Amazon) Code basics

More information

Lecture 5 Tao Wang 1

Lecture 5 Tao Wang 1 Lecture 5 Tao Wang 1 Objectives In this chapter, you will learn about: Selection criteria Relational operators Logical operators The if-else statement Nested if statements C++ for Engineers and Scientists,

More information

CS130/230 Lecture 12 Advanced Forms and Visual Basic for Applications

CS130/230 Lecture 12 Advanced Forms and Visual Basic for Applications CS130/230 Lecture 12 Advanced Forms and Visual Basic for Applications Friday, January 23, 2004 We are going to continue using the vending machine example to illustrate some more of Access properties. Advanced

More information

DATABASE AUTOMATION USING VBA (ADVANCED MICROSOFT ACCESS, X405.6)

DATABASE AUTOMATION USING VBA (ADVANCED MICROSOFT ACCESS, X405.6) Technology & Information Management Instructor: Michael Kremer, Ph.D. Database Program: Microsoft Access Series DATABASE AUTOMATION USING VBA (ADVANCED MICROSOFT ACCESS, X405.6) AGENDA 3. Executing VBA

More information

Introduction to Computer Science Midterm 3 Fall, Points

Introduction to Computer Science Midterm 3 Fall, Points Introduction to Computer Science Fall, 2001 100 Points Notes 1. Tear off this sheet and use it to keep your answers covered at all times. 2. Turn the exam over and write your name next to the staple. Do

More information

Outline. Example: Entertaining Friends. Modular Programming. Example: Entertaining Friends. Example: Entertaining Friends. Lecture 1.

Outline. Example: Entertaining Friends. Modular Programming. Example: Entertaining Friends. Example: Entertaining Friends. Lecture 1. Outline IMS1906 Programming in VB.NET Week 9 Lectures 1 & 2 Subroutines and Parameter Passing Angela Carbone MonashUniversity School of Information Management and Systems Lecture 1 Modules in Algorithms

More information

Unit 6 - Software Design and Development LESSON 3 KEY FEATURES

Unit 6 - Software Design and Development LESSON 3 KEY FEATURES Unit 6 - Software Design and Development LESSON 3 KEY FEATURES Last session 1. Language generations. 2. Reasons why languages are used by organisations. 1. Proprietary or open source. 2. Features and tools.

More information

Cambridge Assessment International Education Cambridge International General Certificate of Secondary Education. Published

Cambridge Assessment International Education Cambridge International General Certificate of Secondary Education. Published Cambridge Assessment International Education Cambridge International General Certificate of Secondary Education COMPUTER SCIENCE 078/3 Paper MARK SCHEME Maximum Mark: 50 Published This mark scheme is published

More information

Q1: Multiple choice / 20 Q2: C input/output; operators / 40 Q3: Conditional statements / 40 TOTAL SCORE / 100 EXTRA CREDIT / 10

Q1: Multiple choice / 20 Q2: C input/output; operators / 40 Q3: Conditional statements / 40 TOTAL SCORE / 100 EXTRA CREDIT / 10 EECE.2160: ECE Application Programming Spring 2016 Exam 1 February 19, 2016 Name: Section (circle 1): 201 (8-8:50, P. Li) 202 (12-12:50, M. Geiger) For this exam, you may use only one 8.5 x 11 double-sided

More information

NOTES: Procedures (module 15)

NOTES: Procedures (module 15) Computer Science 110 NAME: NOTES: Procedures (module 15) Introduction to Procedures When you use a top-down, structured program design, you take a problem, analyze it to determine what the outcome should

More information

Scheme of work Cambridge International AS & A Level Computing (9691)

Scheme of work Cambridge International AS & A Level Computing (9691) Scheme of work Cambridge International AS & A Level Computing (9691) Unit 2: Practical programming techniques Recommended prior knowledge Students beginning this course are not expected to have studied

More information

Unit 4 Advanced Features of VB.Net

Unit 4 Advanced Features of VB.Net Dialog Boxes There are many built-in dialog boxes to be used in Windows forms for various tasks like opening and saving files, printing a page, providing choices for colors, fonts, page setup, etc., to

More information

Lab # 02. Basic Elements of C++ _ Part1

Lab # 02. Basic Elements of C++ _ Part1 Lab # 02 Basic Elements of C++ _ Part1 Lab Objectives: After performing this lab, the students should be able to: Become familiar with the basic components of a C++ program, including functions, special

More information

Cambridge Assessment International Education Cambridge International Advanced Subsidiary and Advanced Level. Published

Cambridge Assessment International Education Cambridge International Advanced Subsidiary and Advanced Level. Published Cambridge Assessment International Education Cambridge International Advanced Subsidiary and Advanced Level COMPUTER SCIENCE 9608/41 Paper 4 Written Paper MARK SCHEME Maximum Mark: 75 Published This mark

More information

VARIABLES. 1. STRINGS Data with letters and/or characters 2. INTEGERS Numbers without decimals 3. FLOATING POINT NUMBERS Numbers with decimals

VARIABLES. 1. STRINGS Data with letters and/or characters 2. INTEGERS Numbers without decimals 3. FLOATING POINT NUMBERS Numbers with decimals VARIABLES WHAT IS A VARIABLE? A variable is a storage location in the computer s memory, used for holding information while the program is running. The information that is stored in a variable may change,

More information

Unit 6 - Software Design and Development LESSON 3 KEY FEATURES

Unit 6 - Software Design and Development LESSON 3 KEY FEATURES Unit 6 - Software Design and Development LESSON 3 KEY FEATURES Last session 1. Language generations. 2. Reasons why languages are used by organisations. 1. Proprietary or open source. 2. Features and tools.

More information

Cambridge Assessment International Education Cambridge International Advanced Subsidiary and Advanced Level. Published

Cambridge Assessment International Education Cambridge International Advanced Subsidiary and Advanced Level. Published Cambridge Assessment International Education Cambridge International Advanced Subsidiary and Advanced Level COMPUTER SCIENCE 9608/21 Paper 2 Written Paper MARK SCHEME Maximum Mark: 75 Published This mark

More information

One Dimension Arrays 1

One Dimension Arrays 1 One Dimension Arrays 1 Array n Many applications require multiple data items that have common characteristics In mathematics, we often express such groups of data items in indexed form: n x 1, x 2, x 3,,

More information

w w w. p a f c i t y. w o r d p r e s s. c o m

w w w. p a f c i t y. w o r d p r e s s. c o m 1 P a g e 2 P a g e 2.1 Algorithm design and problem-solving Candidates should be able to: 2.1.1 Problem-solving and design show understanding that every computer system is made up of sub-systems, which

More information

2.2 Data representation

2.2 Data representation An array is a data structure, which allows a set of items of identical data type to be stored together using the same identifier name. Arrays are declared in a similar way to standard variables, except

More information

OCR Pseudocode to Python

OCR Pseudocode to Python OCR Pseudocode to Python Syntax Topic OCR Pseudocode Result Python Local variables x = 10 x = 10 playername = "Sam" playername = "Sam" Global variables global currentuserid = 223 In Python, variables are

More information

Advanced Computer Programming

Advanced Computer Programming Hazırlayan Yard. Doç. Dr. Mehmet Fidan VARIABLE TYPES Integral Types: In C#, an integral is a category of types. For anyone confused because the word Integral sounds like a mathematical term, from the

More information

Before We Begin. Introduction to Computer Use II. Overview (1): Winter 2006 (Section M) CSE 1530 Winter Bill Kapralos.

Before We Begin. Introduction to Computer Use II. Overview (1): Winter 2006 (Section M) CSE 1530 Winter Bill Kapralos. Winter 2006 (Section M) Topic E: Subprograms Functions and Procedures Wednesday, March 8 2006 CSE 1530, Winter 2006, Overview (1): Before We Begin Some administrative details Some questions to consider

More information

ISRA University Faculty of IT. Textbook BARBARA DOYLE C# Programming: From Problem Analysis to Program Design 4 th Edition

ISRA University Faculty of IT. Textbook BARBARA DOYLE C# Programming: From Problem Analysis to Program Design 4 th Edition 4 Programming Fundamentals 605116 ISRA University Faculty of IT Textbook BARBARA DOYLE C# Programming: From Problem Analysis to Program Design 4 th Edition Prepared by IT Faculty members 1 5 Console Input

More information

Procedural programs are ones in which instructions are executed in the order defined by the programmer.

Procedural programs are ones in which instructions are executed in the order defined by the programmer. Procedural programs are ones in which instructions are executed in the order defined by the programmer. Procedural languages are often referred to as third generation languages and include FORTRAN, ALGOL,

More information

Programmer-Defined Functions

Programmer-Defined Functions Functions Programmer-Defined Functions Local Variables in Functions Overloading Function Names void Functions, Call-By-Reference Parameters in Functions Programmer-Defined Functions function declaration

More information

Cambridge Assessment International Education Cambridge International Advanced Subsidiary and Advanced Level. Published

Cambridge Assessment International Education Cambridge International Advanced Subsidiary and Advanced Level. Published Cambridge Assessment International Education Cambridge International Advanced Subsidiary and Advanced Level COMPUTER SCIENCE 9608/23 Paper 2 Written Paper MARK SCHEME Maximum Mark: 75 Published This mark

More information

Excel VBA Variables, Data Types & Constant

Excel VBA Variables, Data Types & Constant Excel VBA Variables, Data Types & Constant Variables are used in almost all computer program and VBA is no different. It's a good practice to declare a variable at the beginning of the procedure. It is

More information

Programming Studio #9 ECE 190

Programming Studio #9 ECE 190 Programming Studio #9 ECE 190 Programming Studio #9 Concepts: Functions review 2D Arrays GDB Announcements EXAM 3 CONFLICT REQUESTS, ON COMPASS, DUE THIS MONDAY 5PM. NO EXTENSIONS, NO EXCEPTIONS. Functions

More information

COMS 3101 Programming Languages: Perl. Lecture 2

COMS 3101 Programming Languages: Perl. Lecture 2 COMS 3101 Programming Languages: Perl Lecture 2 Fall 2013 Instructor: Ilia Vovsha http://www.cs.columbia.edu/~vovsha/coms3101/perl Lecture Outline Control Flow (continued) Input / Output Subroutines Concepts:

More information

Introduction to Computer Programming Using FORTRAN 77

Introduction to Computer Programming Using FORTRAN 77 Introduction to Computer Programming Using FORTRAN 77 Al-Dhaher, K. Garout, Y. Lafi, A. Al-Muhtaseb, H. Nazzal, A. Saeed, M. Yazdani, J. Zeidan, Y. August 1995 Second Edition Information and Computer Science

More information

Lesson 10 Using and Sorting Lists

Lesson 10 Using and Sorting Lists Lesson What you will learn: how to create variables how to create lists how to add values to lists how to create ordered lists how to use IF ELSE how to create a list in a random order with no duplicates

More information

More on Arrays CS 16: Solving Problems with Computers I Lecture #13

More on Arrays CS 16: Solving Problems with Computers I Lecture #13 More on Arrays CS 16: Solving Problems with Computers I Lecture #13 Ziad Matni Dept. of Computer Science, UCSB Announcements Homework #12 due today No homework assigned today!! Lab #7 is due on Monday,

More information

Unit: Rational Number Lesson 3.1: What is a Rational Number? Objectives: Students will compare and order rational numbers.

Unit: Rational Number Lesson 3.1: What is a Rational Number? Objectives: Students will compare and order rational numbers. Unit: Rational Number Lesson 3.: What is a Rational Number? Objectives: Students will compare and order rational numbers. (9N3) Procedure: This unit will introduce the concept of rational numbers. This

More information

BASIC ELEMENTS OF A COMPUTER PROGRAM

BASIC 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 information

General Certificate of Education Advanced Subsidiary Examination June 2010

General Certificate of Education Advanced Subsidiary Examination June 2010 General Certificate of Education Advanced Subsidiary Examination June 2010 Computing COMP1/PM/C# Unit 1 Problem Solving, Programming, Data Representation and Practical Exercise Preliminary Material A copy

More information

Statements and Operators

Statements and Operators Statements and Operators Old Content - visit altium.com/documentation Mod ifi ed by Rob Eva ns on Feb 15, 201 7 Parent page: EnableBasic Enable Basic Statements Do...Loop Conditional statement that repeats

More information

20. VB Programming Fundamentals Variables and Procedures

20. VB Programming Fundamentals Variables and Procedures 20. VB Programming Fundamentals Variables and Procedures 20.1 Variables and Constants VB, like other programming languages, uses variables for storing values. Variables have a name and a data type. Array

More information

TABLE OF CONTENTS 2 CHAPTER 1 3 CHAPTER 2 4 CHAPTER 3. Algorithm Design & Problem Solving. Programming. Databases

TABLE OF CONTENTS 2 CHAPTER 1 3 CHAPTER 2 4 CHAPTER 3. Algorithm Design & Problem Solving. Programming. Databases 2 CHAPTER 1 Algorithm Design & Problem Solving 3 CHAPTER 2 Programming 4 CHAPTER 3 Databases TABLE OF CONTENTS 1. ALGORITHM DESIGN & PROBLEM-SOLVING 1.1 Problem-solving & Design Every computer system is

More information

UNIVERSITY OF THE FREE STATE DEPARTMENT OF COMPUTER SCIENCE AND INFORMATICS CSIS1614

UNIVERSITY OF THE FREE STATE DEPARTMENT OF COMPUTER SCIENCE AND INFORMATICS CSIS1614 UNIVERSITY OF THE FREE STATE DEPARTMENT OF COMPUTER SCIENCE AND INFORMATICS CSIS1614 DATE: 7 May 2015 MARKS: 130 ASSESSOR: Prof. P.J. Blignaut (Bonus marks: 5) MODERATOR: Dr. L. de Wet TIME: 180 minutes

More information

Introduction To C#.NET

Introduction To C#.NET Introduction To C#.NET Microsoft.Net was formerly known as Next Generation Windows Services(NGWS).It is a completely new platform for developing the next generation of windows/web applications. However

More information

Reusing this material

Reusing this material Modules Reusing this material This work is licensed under a Creative Commons Attribution- NonCommercial-ShareAlike 4.0 International License. http://creativecommons.org/licenses/by-ncsa/4.0/deed.en_us

More information

Variable A variable is a value that can change during the execution of a program.

Variable 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 information

Outline. Parts 1 to 3 introduce and sketch out the ideas of OOP. Part 5 deals with these ideas in closer detail.

Outline. Parts 1 to 3 introduce and sketch out the ideas of OOP. Part 5 deals with these ideas in closer detail. OOP in Java 1 Outline 1. Getting started, primitive data types and control structures 2. Classes and objects 3. Extending classes 4. Using some standard packages 5. OOP revisited Parts 1 to 3 introduce

More information

Lecture 6. Statements

Lecture 6. Statements Lecture 6 Statements 1 Statements This chapter introduces the various forms of C++ statements for composing programs You will learn about Expressions Composed instructions Decision instructions Loop instructions

More information

V2 3/5/2012. Programming in C. Introduction to Arrays. 111 Ch 07 A 1. Introduction to Arrays

V2 3/5/2012. Programming in C. Introduction to Arrays. 111 Ch 07 A 1. Introduction to Arrays Programming in C 1 Introduction to Arrays A collection of variable data Same name Same type Contiguous block of memory Can manipulate or use Individual variables or List as one entity 2 Celsius temperatures:

More information

Cambridge Assessment International Education Cambridge International Advanced Subsidiary and Advanced Level. Published

Cambridge Assessment International Education Cambridge International Advanced Subsidiary and Advanced Level. Published Cambridge Assessment International Education Cambridge International Advanced Subsidiary and Advanced Level COMPUTER SCIENCE 9608/22 Paper 2 Written Paper MARK SCHEME Maximum Mark: 75 Published This mark

More information

Console Input / Output

Console Input / Output Table of Contents Console Input / Output Printing to the Console Printing Strings and Numbers Reading from the Console Reading Characters Reading Strings Parsing Strings to Numeral Types Reading Numeral

More information

CISC220 Lab 2: Due Wed, Sep 26 at Midnight (110 pts)

CISC220 Lab 2: Due Wed, Sep 26 at Midnight (110 pts) CISC220 Lab 2: Due Wed, Sep 26 at Midnight (110 pts) For this lab you may work with a partner, or you may choose to work alone. If you choose to work with a partner, you are still responsible for the lab

More information

We ve covered enough material so far that we can write very sophisticated programs. Let s cover a few more examples that use arrays.

We ve covered enough material so far that we can write very sophisticated programs. Let s cover a few more examples that use arrays. Arrays Part 2 We ve covered enough material so far that we can write very sophisticated programs. Let s cover a few more examples that use arrays. First, once in a while it may be useful to be able to

More information

Fundamentals of Computing and Digital Literacy. Sample. Marking Scheme

Fundamentals of Computing and Digital Literacy. Sample. Marking Scheme Fundamentals of Computing and Digital Literacy Sample Marking Scheme This Marking Scheme has been prepared as a guide only to markers. This is not a set of model answers, nor is the Marking Scheme exclusive,

More information

CSC 112 :: Test #2 Study Guide with Answers April 25, 2012 Short Answer Questions

CSC 112 :: Test #2 Study Guide with Answers April 25, 2012 Short Answer Questions CSC 112 :: Test #2 Study Guide with Answers April 25, 2012 Short Answer Questions (1-6) Regarding the code for Lab #7: Private Const NUMLABELS As Integer = 5 Private lblelement(numlabels) As Label ' Array

More information

AIS Cube [THE BLAZINGCORE SERIES] LANGUAGE REFERENCE

AIS Cube [THE BLAZINGCORE SERIES] LANGUAGE REFERENCE AIS Cube LANGUAGE REFERENCE [THE BLAZINGCORE SERIES] With superior number crunching abilities and peripheral handling on our custom embedded OS, Rapid prototyping is now easy... and blazing fast. Sonata

More information

Faculty of Engineering Computer Engineering Department Islamic University of Gaza C++ Programming Language Lab # 6 Functions

Faculty of Engineering Computer Engineering Department Islamic University of Gaza C++ Programming Language Lab # 6 Functions Faculty of Engineering Computer Engineering Department Islamic University of Gaza 2013 C++ Programming Language Lab # 6 Functions C++ Programming Language Lab # 6 Functions Objective: To be familiar with

More information

QUIZ: What value is stored in a after this

QUIZ: What value is stored in a after this QUIZ: What value is stored in a after this statement is executed? Why? a = 23/7; QUIZ evaluates to 16. Lesson 4 Statements, Expressions, Operators Statement = complete instruction that directs the computer

More information

AIS Cube [THE BLAZINGCORE SERIES] LANGUAGE REFERENCE

AIS Cube [THE BLAZINGCORE SERIES] LANGUAGE REFERENCE AIS Cube LANGUAGE REFERENCE [THE BLAZINGCORE SERIES] With superior number crunching abilities and peripheral handling on our custom embedded OS, Rapid prototyping is now easy... and blazing fast. Sonata

More information

A Crash Course on Limits (in class worksheet)

A Crash Course on Limits (in class worksheet) A Crash Course on Limits (in class worksheet) Many its may be found easily by simple substitution. For example: x x x ( ) = f() = and x = f () = 8 7 and x x = f () = So the first rule is to always TRY

More information

MARK SCHEME for the May/June 2011 question paper for the guidance of teachers 9691 COMPUTING. 9691/23 Paper 2 (Written Paper), maximum raw mark 75

MARK SCHEME for the May/June 2011 question paper for the guidance of teachers 9691 COMPUTING. 9691/23 Paper 2 (Written Paper), maximum raw mark 75 UNIVERSITY OF CAMBRIDGE INTERNATIONAL EXAMINATIONS GCE Advanced Subsidiary Level and GCE Advanced Level MARK SCHEME for the May/June 2011 question paper for the guidance of teachers 9691 COMPUTING 9691/23

More information

COBOL 13. Language Summary. Version 0.01

COBOL 13. Language Summary. Version 0.01 COBOL 13 Language Summary Version 0.01 Bryan Silvia Theory of Programming Languages Alan Labouseur Due: 16 May 2013 1. Introduction COBOL traditionally stands for Completely Obsolete Burdensome Old Language.

More information

May not be distributed except as part of a system distributed by a registered AltFileSearch licensee

May not be distributed except as part of a system distributed by a registered AltFileSearch licensee Class AltFileSearch AltFileSearch Copyright  Codematic Limited 2008. All rights reserved. May not be distributed except as part of a system distributed by a registered AltFileSearch licensee If you received

More information

Herefordshire College of Technology Centre Edexcel BTEC Level 3 Extended Diploma in Information Technology (Assignment 1 of 3)

Herefordshire College of Technology Centre Edexcel BTEC Level 3 Extended Diploma in Information Technology (Assignment 1 of 3) Student: Candidate Number: Assessor: Len Shand Herefordshire College of Technology Centre 24150 Edexcel BTEC Level 3 Extended Diploma in Information Technology (Assignment 1 of 3) Course: Unit: Title:

More information

EE 472 Embedded Systems. Name solutions. Instructions:

EE 472 Embedded Systems. Name solutions. Instructions: Name solutions Instructions: Write your name and student id on every page. You may not consult any other materials or anyone in the class. If you are unsure of what a question is asking, write your assumptions

More information

9691 COMPUTING. 9691/22 Paper 2 (Written Paper), maximum raw mark 75

9691 COMPUTING. 9691/22 Paper 2 (Written Paper), maximum raw mark 75 CAMBRIDGE INTERNATIONAL EXAMINATIONS Cambridge International Advanced Subsidiary and Advanced Level MARK SCHEME for the May/June 2015 series 9691 COMPUTING 9691/22 Paper 2 (Written Paper), maximum raw

More information

Unit 4. Lesson 4.1. Managing Data. Data types. Introduction. Data type. Visual Basic 2008 Data types

Unit 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 information

Microsoft Visual Basic 2005: Reloaded

Microsoft Visual Basic 2005: Reloaded Microsoft Visual Basic 2005: Reloaded Second Edition Chapter 4 Making Decisions in a Program Objectives After studying this chapter, you should be able to: Include the selection structure in pseudocode

More information

Final exam. Final exam will be 12 problems, drop any 2. Cumulative up to and including week 14 (emphasis on weeks 9-14: classes & pointers)

Final exam. Final exam will be 12 problems, drop any 2. Cumulative up to and including week 14 (emphasis on weeks 9-14: classes & pointers) Review Final exam Final exam will be 12 problems, drop any 2 Cumulative up to and including week 14 (emphasis on weeks 9-14: classes & pointers) 2 hours exam time, so 12 min per problem (midterm 2 had

More information

x = 3 * y + 1; // x becomes 3 * y + 1 a = b = 0; // multiple assignment: a and b both get the value 0

x = 3 * y + 1; // x becomes 3 * y + 1 a = b = 0; // multiple assignment: a and b both get the value 0 6 Statements 43 6 Statements The statements of C# do not differ very much from those of other programming languages. In addition to assignments and method calls there are various sorts of selections and

More information

For loops, nested loops and scopes. Jordi Cortadella Department of Computer Science

For loops, nested loops and scopes. Jordi Cortadella Department of Computer Science For loops, nested loops and scopes Jordi Cortadella Department of Computer Science Outline For loops Scopes Nested loops Introduction to Programming Dept. CS, UPC 2 Calculate x y Algorithm: repeated multiplication

More information

Objectives. Introduce the core C# language features class Main types variables basic input and output operators arrays control constructs comments

Objectives. Introduce the core C# language features class Main types variables basic input and output operators arrays control constructs comments Basics Objectives Introduce the core C# language features class Main types variables basic input and output operators arrays control constructs comments 2 Class Keyword class used to define new type specify

More information

Heap sort. Carlos Moreno uwaterloo.ca EIT

Heap sort. Carlos Moreno uwaterloo.ca EIT Carlos Moreno cmoreno @ uwaterloo.ca EIT-4103 http://xkcd.com/835/ https://ece.uwaterloo.ca/~cmoreno/ece250 Standard reminder to set phones to silent/vibrate mode, please! Last time, on ECE-250... Talked

More information

Higher Computing Science Software Design and Development - Programming Summary Notes

Higher Computing Science Software Design and Development - Programming Summary Notes Higher Computing Science Software Design and Development - Programming Summary Notes Design notations A design notation is the method we use to write down our program design. Pseudocode is written using

More information

Functions. Lab 4. Introduction: A function : is a collection of statements that are grouped together to perform an operation.

Functions. Lab 4. Introduction: A function : is a collection of statements that are grouped together to perform an operation. Lab 4 Functions Introduction: A function : is a collection of statements that are grouped together to perform an operation. The following is its format: type name ( parameter1, parameter2,...) { statements

More information

Software Development Techniques. December Sample Exam Marking Scheme

Software Development Techniques. December Sample Exam Marking Scheme Software Development Techniques December 2015 Sample Exam Marking Scheme This marking scheme has been prepared as a guide only to markers. This is not a set of model answers, or the exclusive answers to

More information

Lecture 23: Pointer Arithmetic

Lecture 23: Pointer Arithmetic Lecture 23: Pointer Arithmetic Wai L. Khoo Department of Computer Science City College of New York November 29, 2011 Wai L. Khoo (CS@CCNY) Lecture 23 November 29, 2011 1 / 14 Pointer Arithmetic Pointer

More information

CS121: Computer Programming I

CS121: Computer Programming I CS121: Computer Programming I A) Practice with Java Control Structures B) Methods Dr Olly Gotel ogotel@pace.edu http://csis.pace.edu/~ogotel Having problems? -- Come see me or call me in my office hours

More information

This Week s Agenda (Part A) CS121: Computer Programming I. Changing Between Loops. Things to do in-between Classes. Answer. Combining Statements

This Week s Agenda (Part A) CS121: Computer Programming I. Changing Between Loops. Things to do in-between Classes. Answer. Combining Statements CS121: Computer Programming I A) Practice with Java Control Structures B) Methods Dr Olly Gotel ogotel@pace.edu http://csis.pace.edu/~ogotel Having problems? -- Come see me or call me in my office hours

More information

To become familiar with array manipulation, searching, and sorting.

To become familiar with array manipulation, searching, and sorting. ELECTRICAL AND COMPUTER ENGINEERING 06-88-211: COMPUTER AIDED ANALYSIS LABORATORY EXPERIMENT #2: INTRODUCTION TO ARRAYS SID: OBJECTIVE: SECTIONS: Total Mark (out of 20): To become familiar with array manipulation,

More information

Pointers, References and Arrays

Pointers, References and Arrays Dr. Roxana Dumitrescu Department of Mathematics King s College London email: roxana.dumitrescu@kcl.ac.uk Exercises C++ SHEET 2 Pointers, References and Arrays Problem 1. Declare int variables x and y and

More information