P1PMF Split1 QBASIC. P1PMF Split2QBasic Command Prompt Will launch the emulator DOS operating system? Press Alt + Enter to display the widescreen.

Slides:



Advertisements
Similar presentations
Introduction to Programming using Matlab Session 2 P DuffourJan 2008.
Advertisements

Chapter 3 – Fundamental Statements
Objectives Understand the software development lifecycle Perform calculations Use decision structures Perform data validation Use logical operators Use.
Lecture 2 Introduction to C Programming
Introduction to C Programming
1 Chapter 2 Introduction to Java Applications Introduction Java application programming Display ____________________ Obtain information from the.
Introduction to C Programming
1 Outline 13.1Introduction 13.2A Simple Program: Printing a Line of Text in a Web Page 13.3Another JavaScript Program: Adding Integers 13.4Memory Concepts.
COMP 4—Power Tools for the Mind1 PowerTools What’s in the Box? Turing 1: An Introduction to Programming You will learn elementary computer programming.
 2007 Pearson Education, Inc. All rights reserved Introduction to C Programming.
Guide To UNIX Using Linux Third Edition
Introduction to C Programming
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.
C++ Programming Language Day 1. What this course covers Day 1 – Structure of C++ program – Basic data types – Standard input, output streams – Selection.
Chapter Seven Advanced Shell Programming. 2 Lesson A Developing a Fully Featured Program.
Chapter 1 – Introduction to Computer Systems & QBasic
Advanced Shell Programming. 2 Objectives Use techniques to ensure a script is employing the correct shell Set the default shell Configure Bash login and.
PHP : Hypertext Preprocessor
Working with Numbers in Alice - Converting to integers and to strings - Rounding numbers. - Truncating Numbers Samantha Huerta under the direction of Professor.
Fortran 1- Basics Chapters 1-2 in your Fortran book.
Introduction to Python
E0001 Computers in Engineering
1 Κατανεμημένες Διαδικτυακές Εφαρμογές Πολυμέσων Γιάννης Πετράκης.
Copyright © 2012 Pearson Education, Inc. Publishing as Pearson Addison-Wesley C H A P T E R 2 Input, Processing, and Output.
08/10/ Iteration Loops For … To … Next. 208/10/2015 Learning Objectives Define a program loop. State when a loop will end. State when the For.
PYTHON: PART 2 Catherine and Annie. VARIABLES  That last program was a little simple. You probably want something a little more challenging.  Let’s.
Input, Output, and Processing
Shell Script Programming. 2 Using UNIX Shell Scripts Unlike high-level language programs, shell scripts do not have to be converted into machine language.
Linux Operations and Administration
1 Κατανεμημένες Διαδικτυακές Εφαρμογές Πολυμέσων Γιάννης Πετράκης.
Programming Fundamentals. Today’s Lecture Why do we need Object Oriented Language C++ and C Basics of a typical C++ Environment Basic Program Construction.
 Pearson Education, Inc. All rights reserved Introduction to Java Applications.
What does C store? >>A = [1 2 3] >>B = [1 1] >>[C,D]=meshgrid(A,B) c) a) d) b)
Copyright © 2012 Pearson Education, Inc. Publishing as Pearson Addison-Wesley C H A P T E R 2 Input, Processing, and Output.
1 Computer Science of Graphics and Games MONT 105S, Spring 2009 Session 1 Simple Python Programs Using Print, Variables, Input.
Chapter 1 – Matlab Overview EGR1302. Desktop Command window Current Directory window Command History window Tabs to toggle between Current Directory &
Programming, an introduction to Pascal
XP Tutorial 8 Adding Interactivity with ActionScript.
Chapter 2 part #1 C++ Program Structure
A first program 1. #include 2. using namespace std; 3. int main() { 4. cout
Lesson 4-Mastering the Visual Editor. Overview Introducing the visual editor. Working in an existing file with vi. Understanding the visual editor. Navigating.
 2000 Deitel & Associates, Inc. All rights reserved. Outline 8.1Introduction 8.2A Simple Program: Printing a Line of Text in a Web Page 8.3Another JavaScript.
Shell Scripting – Putting it All Together. Agenda Escaping Characters Wildcards Redirecting Output Chaining and Conditional Chaining Unnamed and Named.
Lecture 26: Reusable Methods: Enviable Sloth. Creating Function M-files User defined functions are stored as M- files To use them, they must be in the.
Introduction to Python Dr. José M. Reyes Álamo. 2 Three Rules of Programming Rule 1: Think before you program Rule 2: A program is a human-readable set.
CSC 1010 Programming for All Lecture 3 Useful Python Elements for Designing Programs Some material based on material from Marty Stepp, Instructor, University.
31/01/ Selection If selection construct.
CMP 131 Introduction to Computer Programming Violetta Cavalli-Sforza Week 5, Lecture 2 (Tuesday)
Microsoft Visual Basic 2012 CHAPTER FOUR Variables and Arithmetic Operations.
Perl for Bioinformatics Part 2 Stuart Brown NYU School of Medicine.
 2003 Prentice Hall, Inc. All rights reserved Basics of a Typical C++ Environment C++ systems –Program-development environment –Language –C++
Subroutines (PrArith, Math,projCP1, PrAdrProc, PrAdrProcFunc) Please use speaker notes for additional information!
1 Agenda  Unit 7: Introduction to Programming Using JavaScript T. Jumana Abu Shmais – AOU - Riyadh.
Chapter 1.2 Introduction to C++ Programming
Topics Designing a Program Input, Processing, and Output
Chapter 1.2 Introduction to C++ Programming
Chapter 1.2 Introduction to C++ Programming
Project 9 Creating Pop-up Windows, Adding Scrolling Messages, and Validating Forms.
Intro to PHP & Variables
Variables and Arithmetic Operations
Chapter 4 LOOPS © Bobby Hoggard, Department of Computer Science, East Carolina University / These slides may not be used or duplicated without permission.
WEB PROGRAMMING JavaScript.
T. Jumana Abu Shmais – AOU - Riyadh
Introduction to TouchDevelop
Additional Topics in VB.NET
Topics Designing a Program Input, Processing, and Output
Programs written in C and C++ can run on many different computers
Topics Designing a Program Input, Processing, and Output
Introduction to C Programming
Presentation transcript:

P1PMF Split1 QBASIC

P1PMF Split2QBasic Command Prompt Will launch the emulator DOS operating system? Press Alt + Enter to display the widescreen

P1PMF Split3QBasic C:\qbasic>qbasic Come to the directory where the QBasic (in this example c: \ qbasic) and start a program qbasic Interface QBasic interpreter. Press the ESC key to close the splash screen

P1PMF Split4

P1PMF Split5 Commands QBASIC's The command tells QBasic interpreter to do something. I can write small or big letters The new line is crossed by pressing the ENTER

P1PMF Split6 Name that may contain value Numerical variables: Basically variables named with just a letter or a word Example X=25, we assigned the value of 25 to the variable X, so tha Qbasic will now know that the variable named x keeps the number 25 PRINT X (run this prog.) The screen will show 25 QBasicVariable

P1PMF Split7 QBasicStrings Strings There are certain types of data (or information) called "strings". Strings containing a string of characters (letters, numbers and symbols) bounded by double quotes. For example, "Hello" is a string. The following list are also strings: " " "Ovojestring" "abc123" "1 + 1 = 2"

Example: b$= “Hello Everyone” PRINT b$ On the screen you will see Hello Everyone P1PMF Split8

P1PMF Split9 QBasicTerms terms The term is something that an interpreter is calculated. For example: (gives 2) (gives 53) 3 * 34 (gives 102) 80 / 4 (gives 20) (100 * 3) + 56 (gives 356)

P1PMF Split10 QBasicPRINT PRINT instruction says QBasic interpreter to print something on the screen. PRINT Press any key to continue

P1PMF Split11 QBasic The First Program PRINT “Hello Everyone" Enter this command and press ENTER Hello Everyone Press any key to continue On the output screen program prints Hello everyone Since the program is carried out, then the bottom of the screen says the message the interpreter waits until any button is pressed to return to the program code

P1PMF Split12 QBasicPRINT PRINT “Hello" PRINT “Everyone" Hello Everyone To print all in the same line, place a semicolon after the PRINT "Hello" PRINT “Hello"; PRINT “Everyone" HelloEveryone You can use multiple print statements in your program. Also, if you put a comma instead of a semicolon, the program will insert spaces between two words. PRINT “Hello", PRINT “Everyone" Hello Everyone

QBasicPRINT The PRINT command can print more than one string on the line, to apply this [ put the ; sign between the variables] Example: Having two variables -name$,which contains name Rob, and age, which contains the number 34,then,to print name and age,you type [ PRINT “name - ” ; name$ ; “Age-” ;age ] On the screen :when program run you will see Name-Rob.Age-34 OR: You can type the program as follows PRINT “Name-” ; name$ PRINT “Age-”;age results : Name-Rob Age-34 P1PMF Split13

P1PMF Split14 File Edit View ┌────────────────┐ │ New │ │ Open... │ │ Save │ │ Save As... │ ├────────────────┤ │ Print... │ ├────────────────┤ │ Exit │ └────────────────┘ QBasic New Program From the File menu choose New to create a new program ┌────────────────────────────────────────────┐ │ │ Loaded file is not saved. Save it now? │ │ ├────────────────────────────────────────────┤ │ └────────────────────────────────────────────┘ Qbasic gives a warning that the program is not saved, choose No to turn up a new program.. Recording program: File - Save * use the tab key to move from one frame to another * select Floppy A * type the name of the program * scroll to Save and press ENTER

P1PMF Split15 Qbasic Variables The variable: is data that is stored in computer memory (RAM). Location variables in RAM is called "address." The following program prints the variable X on the screen: PRINT X 0 Variable X is assigned a free address , and there is 0

P1PMF Split16 QBasicVariable The following program sets the X at 15, and then prints the variable: X = 15 PRINT X 15 Variable X is assigned the value 15

P1PMF Split17 QBasicVariable Variables are accessed line of its name. Variable names can have a combination of letters and numbers. The following list represents the names of valid variables: Y num VALUE xYz abc123

P1PMF Split18 QBasicVariable You can also use multiple variables in the program: X = 82 Y = 101 Z = 79 PRINT X PRINT Y PRINT Z The memory addresses of variables does not have to be exactly the same

P1PMF Split19QBasic PRINT If you close your phrase with quotation marks, then it becomes a string and will not be calculated. For example: PRINT prints the calculated value of the expression.? Delete the current program and enter the following: PRINT " " To clear the output of the screen use the CLS command.

P1PMF Split20 QBasic The variables and expressions x = (10 * 7) PRINT x 570 Also variables can be used as expressions. speed = 50 time = 2 distance = velocity * time PRINT will be from 100 Also can be combined with variable numbers in expressions. X = 100 Y = X * 7 PRINT Y 700

P1PMF Split21 QBasic Variables and Strings If you put a symbol of US dollars ($) to the end of a variable, then the tagging that is a variable of type string. X$ = “Hello Everyone" PRINT X$ Hello Everyone String can be added to the end of the existing string variable. X$ = “Hello" X$ = X$ + “Everyone" PRINT X$ HelloEveryone You can also add a string variable to each other. a$ = "String1" b$ = "String2" c$ = "String3" d$ = a$ + b$ + c$ PRINT d$ String1String2String3

P122

P1PMF Split23 Create the following program: DIM FirstName AS STRING DIM LastName AS STRING CLS INPUT “Enter First Name: “, FirstName INPUT “Enter Last Name: “, LastName PRINT ‘Prints a line of nothing PRINT “Nice To Meet You, “; FirstName ; “ “; LastName If the user entered School Freeware as the first and last name, the program’s output would be: Enter First Name: School Enter Last Name: Freeware Nice To Meet You, School Freeware QBasicINPUT

P1PMF Split24 DIM FirstName AS STRING DIM LastName AS STRING DIM Num1 AS INTEGER DIM Num2 AS INTEGER CLS INPUT “Enter First Name: “, FirstName INPUT “Enter Last Name: “, LastName PRINT ‘Prints a line of nothing PRINT “Nice To Meet You, “; FirstName ; “ “; LastName PRINT INPUT “Enter First Integer To Add: “, Num1 INPUT “Enter Second Integer To Add: “, Num2 PRINT PRINT Num1; “ + “; Num2; “ = “; Num1 + Num2 We can modify the program to allow the user to enter two numbers. The program will add the numbers together.

If the user entered School Freeware as the first and last name, 25 for the first number, and 10 for the second number, the program’s output would be: Enter First Name: School Enter Last Name: Freeware Nice To Meet You, School Freeware Enter First Integer To Add: 25 Enter Second Integer To Add: = 35 P1PMF Split25

QBasicGOTO GOTO means that the program will jump to a particular line We can use GOTO to jump not only back but also forward,to any line you want, the line must be labeled.You can have more than one label P1PMF Split26

QBasic IF….THEN……ELSE This command checks if an argument involving a variable is true,an argument may look like this: IF a=15 THEN …. If the argument is true (and a really equals to 15),the Qbasic executes the command you put after the IF……THEN. IF a=15 THEN PRINT “OK” If the argument is not true(if a is not equal to 15),Qbasic bypasses this line and goes to the next. P1PMF Split

In some cases,you can see the ELSE command,which tells Qbasic exactly what to do if the argument is not true IF a=15 THEN PRINT “OK” ELSE PRINT “It’s not 15” * This example means that if a equals to 15,the computer will show OK on the screen. But if a is not equal to 15,you will see It’s not 15 P1PMF Split28

QBasicIF….THEN……ELSE IF statements are used to check conditions in the program. The structure of the if statement is as follows: If Then Do something ElseIf Then Do something> Else Do something End If P1PMF Split29

QBasicIF….THEN……ELSE The Expression Signs (Relational Operators) For If Statements Are: < Less than <= Less than or equal to > Greater than >= Greater than or equal to = Equal to <> Not Equal to P1PMF Split30

When the condition is met, the code associated with condition will trigger. For example, in a new file type: CLS IF 5 > 2 THEN PRINT “5 Is Greater Than 2” END IF The output will be: 5 Is Greater Than 2 If the greater than changed to a less than, the computer will not output any information because the condition is not met: CLS IF 5 < 2 THEN PRINT “5 Is Less Than 2” END IF P1PMF Split31

CLS IF 5 > 10 THEN PRINT “5 Is Greater Than 10” ELSE PRINT “5 Is Not Greater Than 10” END IF Since 5 is not greater than 10, the output will be: 5 Is Not Greater Than 10 P1PMF Split32

P133 The next example will prompt the user to enter two numbers. The program will check for the greatest number and give a report on its findings. DIM Num1 AS INTEGER DIM Num2 AS INTEGER CLS INPUT "Enter First Number: ", Num1 INPUT "Enter Second Number: ", Num2 IF Num1 > Num2 THEN PRINT Num1; "Is Greater Than"; Num2 ELSEIF Num2 > Num1 THEN PRINT Num2; " Is Greater Than"; Num1 ELSE PRINT “The Numbers Are The Same” END IF The output is dependent on the user input.