True BASIC Ch. 9 Practice Questions. What are the 4 errors? DIM arr(4) FOR X = 1 TO 4 READ arr(X) LET arr(X) = arr(X) * X PRINT What is the new Y INPUT.

Slides:



Advertisements
Similar presentations
What type of data can a variable hold?
Advertisements

2.1 Program Construction In Java
While loops.
Standard Algorithms Find the highest number. ! Your name and today’s date ! Find the maximum Dim numbers(20) As Integer.
Introduction to arrays
Intro Programming By Trevor Decker Team 1743 By Trevor Decker Team 1743.
Loops (Part 1) Computer Science Erwin High School Fall 2014.
CSE 1301 Lecture 6B More Repetition Figures from Lewis, “C# Software Solutions”, Addison Wesley Briana B. Morrison.
Computer Science 1620 Loops.
1 9/29/06CS150 Introduction to Computer Science 1 Loops Section Page 255.
The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL Adrian Ilie COMP 14 Introduction to Programming Adrian Ilie July 5, 2005.
Introduction to Computing Dr. Nadeem A Khan. Lecture 22.
True BASIC Ch. 6 Practice Questions. What is the output? PRINT X LET X = -1 PRINT X FOR X = 4 TO 5 STEP 2 PRINT X NEXT X PRINT X END.
General Computer Science for Engineers CISC 106 Lecture 19 Dr. John Cavazos Computer and Information Sciences 04/06/2009.
TrueBASIC Ch 4 & 5 Sample Problems. What are the errors? (4 total) INPUT age IF age > 7 THEN PRINT "rollercoaster" ELSE PRINT "ferris wheel" IF age
Chapter 6 - Repetition. Introduction u Many applications require certain operations to be carried out more than once. Such situations require repetition.
Switch structure Switch structure selects one from several alternatives depending on the value of the controlling expression. The controlling expression.
Introduction to Computing Dr. Nadeem A Khan. Lecture
Introduction to Computing Dr. Nadeem A Khan. Lecture 24.
Loops – While, Do, For Repetition Statements Introduction to Arrays
CS31: Introduction to Computer Science I Discussion 1A 4/2/2010 Sungwon Yang
1 Chapter 2 Introductory Programs. 2 Getting started To create and run a Java program –Create a text file with a.java extension for the source code. For.
COMP 14 Introduction to Programming Miguel A. Otaduy May 20, 2004.
1 Chapter 7 Arrays. 2 Outline and Objective In this chapter we will Learn about arrays One-dimensional arrays Two-dimensional arrays Learn about searching.
Testing a program Remove syntax and link errors: Look at compiler comments where errors occurred and check program around these lines Run time errors:
TrueBASIC Ch 2 & 3 Sample Problems. What are the errors? (2 total) PRINT "REM" LET REM = 50 reAD currency$, amount DAta "Dollar", 50.
2010/11 : [1]Building Web Applications using MySQL and PHP (W1)PHP Recap.
1 Operating Systems Lecture 3 Shell Scripts. 2 Shell Programming 1.Shell scripts must be marked as executable: chmod a+x myScript 2. Use # to start a.
C++ for Everyone by Cay Horstmann Copyright © 2012 by John Wiley & Sons. All rights reserved For Loops October 16, 2013 Slides by Evan Gallagher.
REPETITION CITS1001. Scope of this lecture Repetition for loops while loops 2.
Arrays Part 9 dbg. Arrays An array is a fixed number of contiguous memory locations, all containing data of the same type, identified by one variable.
1 Flow of control Sequential Executing instructions one by one, in exact order given Selection Choosing to execute a particular set of statements depending.
Copyright © Nancy Acemian 2004 For Loops-Break-Continue COMP For loop is a counter controlled loop. For loop is a pretest loop. Used when number.
CHAPTER SIX LOOPS © Prepared By: Razif Razali 1. FORMAT OR REFRESH!! WHAT HAVE WE LEARN? Differentiate between the types of selection structure? Which.
Flow Control in Java. Controlling which instruction to execute next Sequential  Similar to walking, one step after another Branching  Similar to a fork.
Intro to Nested Looping Intro to Computer Science CS1510 Dr. Sarah Diesburg.
Using Text Files in Excel File I/O Methods. Working With Text Files A file can be accessed in any of three ways: –Sequential access: By far the most common.
Review TEST 2 Chapters 4,5,7. QUESTION For which type of operands does the == operator always work correctly: (a) int, (b) double, or (c) String?
Susie’s lecture notes are in the presenter’s notes, below the slides Disclaimer: Susie may have made errors in transcription or understanding. If there.
5.1 Revision: Ifs and Loops. 5.2 if, elsif, else It’s convenient to test several conditions in one if structure: print "Please enter your grades average:\n";
UniMAP Sem2-10/11 DKT121: Fundamental of Computer Programming1 Arrays.
Agenda  Take up homework  Loops - Continued –For loops Structure / Example involving a for loop  Storing Characters in variables  Introduction to Functions.
1 CS 177 Week 6 Recitation Slides Review for Midterm Exam.
1 Class Chapter Objectives Use a while loop to repeat a series of statements Get data from user through an input dialog box Add error checking.
Midterm Exam Topics (Prof. Chang's section) CMSC 201.
BY ILTAF MEHDI (MCS, MCSE, CCNA)1. INSTRUCTOR: ILTAF MEHDI (MCS, MCSE, CCNA, Web Developer) BY ILTAF MEHDI (MCS, MCSE, CCNA)2 Chapter No: 04 “Loops”
Literals A literal (sometimes called a constant) is a symbol which evaluates to itself, i.e., it is what it appears to be. Examples: 5 int literal
CSC 4630 Meeting 17 March 21, Exam/Quiz Schedule Due to ice, travel, research and other commitments that we all have: –Quiz 2, scheduled for Monday.
CSC 4630 Perl 3 adapted from R. E. Beck. Problem But we worked on it first: Input: Read from a text file named in a command line argument Output: List.
Unit – 3 Control structures. Condition Statements 1.If.…..else :- Has someone ever told you, "if you work hard, then you will succeed"? And what happens.
Learning Javascript From Mr Saem
Chapter 4 Repetition Statements Program Development and Design Using C++, Third Edition.
Arrays. What is an array? An array is a collection of data types. For example, what if I wanted to 10 different integers? int num1; int num2; int num3;
1 Agenda  Unit 7: Introduction to Programming Using JavaScript T. Jumana Abu Shmais – AOU - Riyadh.
CPSC 233 Tutorial January 21 st /22 nd, Linux Commands.
A bit of C programming Lecture 3 Uli Raich.
Loop Structures.
Lecture 07 More Repetition Richard Gesick.
SELECTION STATEMENTS (1)
Lecture 4B More Repetition Richard Gesick
Final Exam Review Part 4 - VBA
Arrays, For loop While loop Do while loop
An Introduction to Python
T. Jumana Abu Shmais – AOU - Riyadh
Fundamentals of visual basic
Arrays.
CS100J Lecture 3 Previous Lecture This Lecture Programming Concepts
Python Basics with Jupyter Notebook
Just Basic Lessons 9 Mr. Kalmes.
Basic 9 Mr. Husch.
Presentation transcript:

True BASIC Ch. 9 Practice Questions

What are the 4 errors? DIM arr(4) FOR X = 1 TO 4 READ arr(X) LET arr(X) = arr(X) * X PRINT What is the new Y INPUT 2Y NEXT X DATA 23, 72, 91

What are the 4 errors? DIM arr(4) FOR X = 1 TO 4 READ arr(X) LET arr(X) = arr(X) * X PRINT "What is the new Y" INPUT Y NEXT X DATA 23, 72, 91, 12 END 1) Missing double quotes around string 2) Variable names cannot start with numbers 3) Insufficient Data – 4 items needed 4) Missing END statement

What are the 5 errors? REM REM cuz'z INPUT PROMPT "What's your name?" : names$(1) DIM names$(3) PRINT "Cousin's name is " : names$(2) PRINT names(2);"’s other cousin's name is"; INPUT names$(3) PRINT names$(1);" & ";names$(3)" are "; " siblings or 2nd cousins" END

What are the 5 errors? REM REM cuz'z DIM names$(3) INPUT PROMPT "What's your name?" : names$(1) INPUT PROMPT "Cousin's name is " : names$(2) PRINT names$(2);"’s other cousin's name is"; INPUT names$(3) PRINT names$(1);" & ";names$(3);" are "; PRINT " siblings or 2nd cousins" END 1)DIM command must come before array is used 2)PRINT should be INPUT prompt 3)names$ is a string array, must end with $ 4)Missing semi-colon to separate items 5)No multi-line PRINT’s, next line must start with PRINT

What is the output? DIM num(2), word$(2) READ word$(1), num(1) DATA "eleven" READ word$(2), num(2) DATA 11, "thirteen", 13 IF num(1)>num(2) THEN PRINT word$(1);" bigger" SELECT CASE word$(2) CASE IS = "thirteen" PRINT "good" CASE "thirteen" PRINT "great" CASE ELSE PRINT "fantastic" END SELECT END

What is the output? DIM num(2), word$(2) READ word$(1), num(1) DATA "eleven" READ word$(2), num(2) DATA 11, "thirteen", 13 IF num(1)>num(2) THEN PRINT word$(1);" bigger" SELECT CASE word$(2) CASE IS = "thirteen" PRINT "good" CASE "thirteen" PRINT "great" CASE ELSE PRINT "fantastic" END SELECT END OUTPUT good

What are the 4 errors? DIM mydata(3) FOR W = 1 TO 3 mydata(W) = 2 LOOP DATA 1,2,3 LET mydata(W) = 3 INPUT mydata(1) PRINT "done" REM yay! END

What are the 4 errors? DIM mydata(3) FOR W = 1 TO 3 LET mydata(W) = 2 NEXT W DATA 1,2,3 LET mydata(W-1) = 3 INPUT mydata(1) PRINT "done" ! yay! END 1) Missing LET in value assignment 2) FOR loop ends with NEXT (variable) 3) W is 4 after loop, which exceeds array bounds. Fix by using W-1 or making array dimension 4 (DIM mydata(4) at top) 4) REM is for a whole line comment. Use ! for an inline comment

What are the 4 errors? DIM arr$(0 TO 3) READ arr$(0 TO 3) SELECT CASE arr$(1) CASE 2 INPUT X CASE ELSE PRINT arr(1) END CASE DATA "1","2", "3", "4" END

What are the 4 errors? DIM arr$(0 TO 3) READ arr$(0),arr$(1),arr$(2),arr$(3) SELECT CASE arr$(1) CASE "2" INPUT X CASE ELSE PRINT arr$(1) END SELECT DATA "1","2", "3", "4" END 1) Cannot READ a range (TO for array appears only in DIM) 2) Missing double quotes around string 3) arr$ is a string array, so it needs a $ 4) SELECT CASE ends with END SELECT

What is the output? DIM nums(1000) LET X = 1 DO LET nums(X) = INT(10 / X^2) LET X = X + 1 LOOP UNTIL nums(X-1) = 0 PRINT "loop iterations = ";(X - 1) FOR Y = 1 TO X-1 PRINT nums(Y) NEXT Y END

What is the output? DIM nums(1000) LET X = 1 DO LET nums(X) = INT(10 / X^2) LET X = X + 1 LOOP UNTIL nums(X-1) = 0 PRINT "loop iterations = ";(X - 1) FOR Y = 1 TO X-1 PRINT nums(Y) NEXT Y END OUTPUT loop iterations =