SlideServe
Menu
Préférences
© SlideServe · v2026

Variables and DeBugging

haley-cantrell avatar
13 diapositives · 265 Views · Nov 20, 2014

This guide covers the fundamentals of variables and debugging in programming. It explains how to use variables to hold values, the importance of naming conventions, and how to declare variables using REM statements. You'll learn about setting values with LET, using variables in calculations, and the significance of clear variable names. Additionally, we explore debugging, including syntax and logical errors, and offer practical debugging exercises to enhance your programming skills.

Variables and DeBugging - slide 1
01 / 13Variables and DeBugging
1 / 17

Télécharger la présentation

Variables and DeBugging
Une image / un lien ci-dessous est fourni (tel quel) pour télécharger la présentation

Politique de téléchargement : le contenu du site vous est fourni TEL QUEL pour votre information et votre usage personnel ; il ne peut être vendu, concédé sous licence ni partagé sur d’autres sites sans l’accord de son auteur.Le contenu vous est fourni TEL QUEL, pour votre information et votre usage personnel uniquement. Téléchargez la présentation en cliquant sur ce lien. Lors du téléchargement, si vous ne parvenez pas à télécharger une présentation, l’éditeur a peut-être supprimé le fichier de son serveur.Pendant le téléchargement, si vous ne parvenez pas à obtenir une présentation, le fichier a peut-être été supprimé par l’éditeur.

F I N

Plus de contenu associé

Transcription de la présentation
  1. Variables and DeBugging Beginning Programming

  2. 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 $

  3. Variable Naming Good Naming Examples Poor Naming Examples • FRUIT$ • POOL.LENGTH • LAST_NAME$ • BIRTHDATE$ • AGE • 1FRUIT$ • F$ • FRUIT TYPE$ • FRUIT*$ • NEWFRUIT$ • FRUIT

  4. Practice • Complete the Creating Descriptive Variable names worksheet • Complete the Storage Location Worksheet

  5. 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

  6. Assignment • Complete REM and Variable Practice Worksheet

  7. 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”

  8. 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; “.”

  9. 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$

  10. 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 ;

  11. Assignment Program #4A

  12. 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

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