Programming constructs

Slides:



Advertisements
Similar presentations
Ch. 3 Variables VB.Net Programming. Data Types Boolean – True or False values Short – Small integers (+/- 32,767) Integer – Medium-size integers (+/-
Advertisements

Operators & Identifiers The Data Elements. Arithmetic Operators exponentiation multiplication division ( real ) division ( integer quotient ) division.
Objectives Understand the software development lifecycle Perform calculations Use decision structures Perform data validation Use logical operators Use.
Variables and Constants
Developing Software Applications Introduction to Programming Fundamentals Scoping in VB Simple Ifs in VB.
Developing Software Applications Introduction to Variables & Data Types in VB State Transition Diagrams.
1 Pertemuan 03 Representing Data Matakuliah: D0524 / Algoritma dan Pemrograman Komputer Tahun: 2005 Versi:
VB Code Statements 3 types of VB statement The Remark statement, known as comments, are used for project documentation only Begin with an apostrophe Not.
To type the VB code behind the command button (named cmdPush), Double-Click on the Push Me (caption) command button As a result the Visual Basic Code Window.
Access VBA Programming for Beginners - Class 1 - by Patrick Lasu
VB DATATYPES, VARIABLES, CONSTANTS & CALCULATIONS.
Visual Basic Fundamental Concepts. Integrated Development Enviroment Generates startup form for new project on which to place controls. Features toolbox.
U SING V ARIABLES IN V ISUAL B ASIC Intermediate 2 Software Development.
06/10/ Working with Data. 206/10/2015 Learning Objectives Explain the circumstances when the following might be useful: Disabling buttons and.
National Diploma Unit 4 Introduction to Software Development Data types, variables and constants.
Access VBA Programming for Beginners - Class 2 - by Patrick Lasu
Chapter 5: Data Types (2013) Revision Candidates should be able to know: Identify different data types? Key terms: File, record, field and key field Database.
3 - Variables Lingma Acheson Department of Computer and Information Science, IUPUI CSCI N331 VB.NET Programming.
Data & Data Types & Simple Math Operation 1 Data and Data Type Standard I/O Simple Math operation.
Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Extended Prelude to Programming Concepts & Design, 3/e by Stewart Venit and.
Operators & Identifiers The Data Elements. Arithmetic Operators exponentiation multiplication division ( real ) division ( integer quotient ) division.
Visual Basic Programming
Microsoft Visual Basic 2005: Reloaded Second Edition Chapter 3 Variables, Constants, Methods, and Calculations.
Variables and Math in Code. Variables A variable is a storage block for information in your program “A” “A” Computer Program Memory Computer Program.
1 Flow Control Ifs, loops. 2 Data Type At the lowest level, all data in a computer is written in 1’s and 0’s (binary) How the data gets interpreted, what.
Relational Databases. Relational database  data stored in tables  must put data into the correct tables  define relationship between tables  primary.
Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Extended Prelude to Programming Concepts & Design, 3/e by Stewart Venit and.
INT213-Week-2 Working with Variables. What is variable
Repetition. Loops Allows the same set of instructions to be used over and over again Starts with the keyword loop and ends with end loop. This will create.
# 1# 1 What is a variable that you create? What is a constant that you create? What is an intrinsic (built-in) constant? What variables are built in?
Clearly Visual Basic: Programming with Visual Basic 2008 Chapter 7 Where Can I Store This?
Programming with Microsoft Visual Basic th Edition
Variables Hold information that may be manipulated, used to manipulate other information or remembered for later use A storage location in memory (RAM)
Chapter 4 Getting Started with VBA. Subroutines Subroutine is the logical section of code that performs a particular task. Subroutine is also called a.
CECS 5020 Computers in Education Visual Basic Variables and Constants.
Variables in VB.NET. Variables  A storage location in memory (RAM)  Holds data/information while the program is running  These storage locations can.
Variables in VB. What is a variable? ► A named memory location that stores a value.
COP 2551 Introduction to Object Oriented Programming with Java Topics –Introduction to the Java language –Code Commenting –Java Program Structure –Identifiers.
Creation of Variables with Numeric, alphanumeric, date, picture, memo data types Constant - A quantity that does not change during the execution of a program.
Chapter 4: Variables, Constants, and Arithmetic Operators Introduction to Programming with C++ Fourth Edition.
Slide 1 Chapter 3 Variables  A variable is a name for a value stored in memory.  Variables are used in programs so that values can be represented with.
© 2006 Lawrenceville Press Slide 1 Chapter 4 Variables  A variable is a name for a value stored in memory.  Variables are created using a declaration.
Visual Basic Declaring Variables Dim x as Integer = 0 In the statement above, x is being declared as an Integer (whole number) and is initialised.
Slide 1 Chapter 3 Variables  A variable is a name for a value stored in memory.  Variables are created using a declaration statement. For example: Dim.
Chapter 9: Data types and data structures OCR Computing for A Level © Hodder Education 2009.
Data Types Mr Tottman Link. Data Types Programs need to use data for calculations and for output to various devices The best programs will always use.
Chapter 2 Variables and Constants. Objectives Explain the different integer variable types used in C++. Declare, name, and initialize variables. Use character.
The purpose of a CPU is to process data Custom written software is created for a user to meet exact purpose Off the shelf software is developed by a software.
DATA TYPES.
Unit 2 Technology Systems
A variable is a name for a value stored in memory.
Introduction to programming
2. Understanding VB Variables
Data Types.
Variables ICS2O.
Visual Basic Programming Chapter Four Notes Working with Variables, Constants, Data Types, and Expressions GROUPBOX CONTROL The _____________________________________.
CIS16 Application Development Programming with Visual Basic
Data Types & File Size Calculations
CS285 Introduction - Visual Basic
Visual Basic Numbers Chapter 3.3 Prepared By: Deborah 1/15/2019.
Building Java Programs
CHAPTER FOUR VARIABLES AND CONSTANTS
VB Variables and Data
Language Constructs Construct means to build or put together. Language constructs refers to those parts which make up a high level programming language.
Spreadsheets, Modelling & Databases
Data Types and Maths Programming Guides.
Just Basic Lessons Mr. Kalmes.
Visual Basic Numbers Chapter 3.3 Prepared By: Deborah 7/9/2019.
Variables and Constants
4d – Program Design Lingma Acheson CSCI N331 VB .NET Programming
Presentation transcript:

Programming constructs The building blocks of programming

Naming and storing data A program is made up of two main parts: a series of instructions the data that will be used. When programming you need to define: where each item of data will be stored what name to give to each item of data. Data can be stored as variables or constants: variables are data items where the values may change as the program is executed constants are data items where the value will stay the same as the program is executed. © 2005 Bob Reeves, Dave Fogg/Hodder Murray

Variables and constants Any item of data where the value may change. For example, a system for recording student grades would have two variables: Student Name Grade. The values assigned to each variable will change as data is entered into the system. In this example it will change every time a new student name and grade are entered. Constants Any item of data where the value remains the same. For example, a system for calculating VAT in invoices would have one constant: VAT set at 17.5%. This value would not change as the program is run as the rate of VAT does not change. © 2005 Bob Reeves, Dave Fogg/Hodder Murray

Data types (1) When data is stored in a program, you must specify what type of data it is so that the program knows how to handle it. For example, you might perform the calculation "2" + "2" but unless you specify that these two items of data are numeric, the answer will be "22". Different programming languages use different names for data types but the basic types are common to all languages. © 2005 Bob Reeves, Dave Fogg/Hodder Murray

Data types (2) Integer: stores whole numbers that may be positive or negative. Real: stores numbers including the use of decimal places – also known as single or double in some languages. Text: stores text or text/numbers – also known as alphanumeric or string in some languages. Boolean: stores data that is either yes/no or true/false. Currency: stores values as pounds and pence. © 2005 Bob Reeves, Dave Fogg/Hodder Murray

How to use the data types A private hospital creates a system to record details about patients. It may use the following variables and data types. A yes/no answer is required Boolean Has the customer paid? Represented as UK sterling Currency Cost of treatment Need to use decimal places Real Height Will be a whole number Integer NumberOfVisits Name is made up of text String Name Explanation Data type Data item © 2005 Bob Reeves, Dave Fogg/Hodder Murray

Declaring variables and constants When you create a program you need to tell the computer (declare) what variable and constants you will be using. It is good practice to declare all the variables and constants that the program will use before you start writing the code. Using the hospital example, the declaration (using VB in this case) would look like this: Dim CustomerName As String Dim NumberOfVisits As Integer Dim CustomerHeight As Single Dim CustomerPaid As Boolean Dim TreatmentCost As Currency Const VAT = 17.5% Dim is short for Dimension and is the term used by VB. Other languages use different terms. VAT has been declared as a constant at 17.5%. The users can also define their own variable types. © 2005 Bob Reeves, Dave Fogg/Hodder Murray

Issues to consider when declaring variables Give variables sensible and meaningful names so that you know what they are later on. In large programs, it is useful to split your code into more manageable sections. Decide whether you want to use each variable in every part of the program or just in certain parts of the code. Local variables are only available in the section of code where they have been declared. Global variables are available everywhere in the program. © 2005 Bob Reeves, Dave Fogg/Hodder Murray