VARIABLES AND DEBUGGING Beginning Programming. Assignment Statements  Used to hold values in a variable  Calculates a result and stores it in a variable.

Slides:



Advertisements
Similar presentations
Variables in C Amir Haider Lecturer.
Advertisements

Chapter 3 – Fundamental Statements
Introduction to PHP MIS 3501, Fall 2014 Jeremy Shafer
1 ICS103 Programming in C Lecture 3: Introduction to C (2)
CP Week 2 zReserved words zVariables zInput and output zData types zTesting and Documentation.
Chapter 2 Basic Elements of Fortan
Chapter 2: Input, Processing, and Output
Computer Science: A Structured Programming Approach Using C1 Objectives ❏ To understand the structure of a C-language program. ❏ To write your first C.
Moving To Code 3 More on the Problem-Solving Process §The final step in the problem-solving process is to evaluate and modify (if necessary) the program.
Chapter 3 Planning Your Solution
Python. What is Python? A programming language we can use to communicate with the computer and solve problems We give the computer instructions that it.
CH1 – A 1 st Program Using C#. Program Set of instructions which tell a computer what to do. Machine Language Basic language computers use to control.
Fortran 1- Basics Chapters 1-2 in your Fortran book.
Programming.
Input & Output: Console
General Programming Introduction to Computing Science and Programming I.
INTRODUCTION TO ALGORITHMS PROGRAMMING. Objectives Give a definition of the term algorithm Describe the various parts of the pseudocode algorithm or algorithm.
CS 127 Writing Simple Programs.  Stages involved  Analyze the problem  Understand as much as possible what is trying to be solved  Determine Specifications.
IPC144 Introduction to Programming Using C Week 1 – Lesson 2
Chapter 2 Overview of C Part I J. H. Wang ( 王正豪 ), Ph. D. Assistant Professor Dept. Computer Science and Information Engineering National Taipei University.
Presenting results to the USER in a professional manner 1. semicolon, disp(), fprintf() 2. Placeholders 3. Special characters 4. Format-modifiers Output.
1 © 2000 John Urrutia. All rights reserved. Qbasic Constructing Qbasic Programs.
Section 2 Variables National 4/5 Scratch Course. What you should know after this lesson What a variable is Where variables are stored How to get data.
Copyright © 2009 Pearson Education, Inc. Publishing as Pearson Addison-Wesley STARTING OUT WITH Python Python First Edition by Tony Gaddis Chapter 2 Input,
E0001 Computers in Engineering Procedures: subprograms and functions.
Input, Output, and Processing
© Copyright 1992–2005 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. Tutorial 5 – Dental Payment Application: Introducing.
Computer Programming 2 Lab(1) I.Fatimah Alzahrani.
1 C++ Programming Basics Chapter 2 Lecture CSIS 10A.
Getting Started with MATLAB 1. Fundamentals of MATLAB 2. Different Windows of MATLAB 1.
Constants Numeric Constants Integer Constants Floating Point Constants Character Constants Expressions Arithmetic Operators Assignment Operators Relational.
1 INTRODUCTION TO PROBLEM SOLVING AND PROGRAMMING.
Copyright © 2012 Pearson Education, Inc. Chapter 2: Introduction to C++
An Object-Oriented Approach to Programming Logic and Design Chapter 1 An Overview of Computers and Logic.
Introduction to Programming with RAPTOR
Copyright © 2012 Pearson Education, Inc. Publishing as Pearson Addison-Wesley C H A P T E R 2 Input, Processing, and Output.
1 Chapter 3 Syntax, Errors, and Debugging Fundamentals of Java: AP Computer Science Essentials, 4th Edition Lambert / Osborne.
Getting Started with MATLAB (part2) 1. Basic Data manipulation 2. Basic Data Understanding 1. The Binary System 2. The ASCII Table 3. Creating Good Variables.
Introduction to Computer Programming
1 Program Planning and Design Important stages before actual program is written.
Chapter 2 Using Variables and Constant. What is a Constant ? The data in COBOL programs falls in two broad categories: – Constants and Variables A constant.
Chapter 4 Variables and constants. 4.1 Variables -Use of variables is good programming style -easier to modify -easier for a programmer to understand.
 2008 Pearson Education, Inc. All rights reserved JavaScript: Introduction to Scripting.
CSC 1010 Programming for All Lecture 3 Useful Python Elements for Designing Programs Some material based on material from Marty Stepp, Instructor, University.
Data And Variables Chapter Names vs. Values Michael Jordan name (the letter sequence used to refer to something) value (the thing itself)
Copyright © 2009 Pearson Education, Inc. Publishing as Pearson Addison-Wesley STARTING OUT WITH Python Python First Edition by Tony Gaddis Chapter 2 Input,
CHAPTER 2 PART #3 C++ INPUT / OUTPUT 1 st Semester King Saud University College of Applied studies and Community Service CSC1101 By: Fatimah.
Chapter Topics 2.1 Designing a Program 2.2 Output, Input, and Variables 2.3 Variable Assignment and Calculations 2.4 Variable Declarations and Data Types.
1 Project 2: Using Variables and Expressions. 222 Project 2 Overview For this project you will work with three programs Circle Paint Ideal_Weight What.
C OMPUTER P ROGRAMMING 1 Input and Variables. I/O S TATEMENTS : I NPUT & V ARIABLES Input is the term used to describe the transfer of information from.
Introduction Chapter 1 1/22/16. Check zyBooks Completion Click on the boxes for each section.
Calculator Program Explained by Arafa Hamed. First Designing The Interface Ask yourself how many places are there that will be used to input numbers?
Variables in C Topics  Naming Variables  Declaring Variables  Using Variables  The Assignment Statement Reading  Sections
Variables in C Topics  Naming Variables  Declaring Variables  Using Variables  The Assignment Statement Reading  Sections
GCSE Computing: Programming GCSE Programming Remembering Python.
CMSC 104, Version 8/061L09VariablesInC.ppt Variables in C Topics Naming Variables Declaring Variables Using Variables The Assignment Statement Reading.
COMPUTER PROGRAMMING Year 9 – lesson 1. Objective and Outcome Teaching Objective We are going to look at how to construct a computer program. We will.
Introducing Python 3 Introduction to Python. Introduction to Python L1 Introducing Python 3 Learning Objectives Know what Python is and some of the applications.
Chapter 3 Using Variables, Constants, Formatting Mrs. UlshaferSept
BASIC ELEMENTS OF A COMPUTER PROGRAM
1-1 Logic and Syntax A computer program is a solution to a problem.
Chapter 2: Input, Processing, and Output
Chapter Topics 2.1 Designing a Program 2.2 Output, Input, and Variables 2.3 Variable Assignment and Calculations 2.4 Variable Declarations and Data Types.
Chapter 2 – Getting Started
CHAPTER FOUR VARIABLES AND CONSTANTS
Chapter 2: Input, Processing, and Output
Variables in C Topics Naming Variables Declaring Variables
Basic 9 Mr. Husch.
Chapter 1 c++ structure C++ Input / Output
Presentation transcript:

VARIABLES AND DEBUGGING Beginning Programming

Assignment Statements  Used to hold values in a variable  Calculates a result and stores it in a variable  Variable: used to hold values in a program  Should describe what it holds  Starts with a letter  Cannot use spaces  Can only use _, $, and.  Cannot use reserved words (such as RUN, NEW, PRINT, etc.)  Should end a string (a sequence of characters enclosed in quotation marks) with $

Variable Naming  FRUIT$  POOL.LENGTH  LAST_NAME$  BIRTHDATE$  AGE  1FRUIT$  F$  FRUIT TYPE$  FRUIT*$  NEWFRUIT$  FRUIT Good Naming ExamplesPoor Naming Examples

Practice  Complete the Creating Descriptive Variable names worksheet  Complete the Storage Location Worksheet

Commenting Variables in REM Statements  You need to list every variable that you use in the program in your REM Statements  You will put there in the Variable Declaration section of the REM Template  You should list the variable name and then describe what the variable stands for  Example:  REM POOL.LENGTH holds the length of the pool in feet  REM TEACHER_NAME$ holds the teachers first and last name

Assignment  Complete REM and Variable Practice Worksheet

Using Variables in the Main Program  To set the value of a variable, use the command LET  Examples: LET Stage.Length = 5 LET Subject_Name$ = “Algebra”  You can also set the value of the variable without the word LET  Examples: Stage.Length = 5 Subject_Name$ = “Algebra”

Using Variables in Processes  You will want to use variable names when solving equations  Example #1: LET Length = 5 LET Width = 4 LET Height = 3 LET Volume = Length * Width * Height PRINT “The volume is “; Volume; “.”

Using Variables in Processes  You will want to use variable names when solving equations  Example #2: LET First.Name$ = “Bob” LET Last.Name$ = “Smith” Customer.Name$ = First.Name$ + “ “ + Last.Name PRINT “The customer’s name is “; Customer.Name$

Some important facts  Try to use variables whenever you can and have the computer solve mathematical equations for you, rather than solving them yourself. If you solve them yourself and just enter the answer, you will have to do it all over again if you want to run the program with different input numbers.  In PRINT statements, remember to separate the parts in quotations with the variables not in quotations with a ;

Assignment Program #4A

Debugging  Debugging: Figuring out the errors in a program  There are 2 types:  Syntax Errors Most common error Programmer violates the grammatical rules of Qbasic Error message will be displayed at bottom of screen  Logical Errors Program may stop executing prematurely Program may execute completely, but produce incorrect results Mathematical errors Formatting errors

Debugging Practice 1. Debugging exercise #1 – complete and we will go over as a class 2. Debugging exercise #2 – complete and turn in for a grade