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 <

Slides:



Advertisements
Similar presentations
Chapter 4 - Control Statements
Advertisements

P1PMF Split1 QBASIC. P1PMF Split2QBasic Command Prompt Will launch the emulator DOS operating system? Press Alt + Enter to display the widescreen.
MATLAB Examples. CS 1112 MATLAB Examples Find the number of positive numbers in a vector x = input( 'Enter a vector: ' ); count = 0; for ii = 1:length(x),
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.
Subject: Information Technology Grade: 10
START DEFINITIONS values (3) N1 = (8, 1,-9) i N1 average N3,2 sum N2 = 0 temp N1 Do not guess or assume any values! Follow the values of the variables.
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.
1 Lab Session-6 CSIT-121 Spring 2005 Structured Choice The do~While Loop Lab Exercises.
Single selection syntax if ( expression ) { statements; } TRUE FALSE expression if clause 1. Statemens are executed when expression is true 2. { } can.
Chapter 4 MATLAB Programming Logical Structures Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
1 10/25/06CS150 Introduction to Computer Science 1 Reading from and Writing to Files.
1 Lab Session-7 CSIT-121 Fall Introducing Structured Choice 4 The do~While Loop 4 Lab Exercises.
JavaScript with Input & Output Step 1: Use tags JavaScript Template.
Lecture Review (If-else Statement) if-else statement has the following syntax: if ( condition ) { statement1; } else { statement2; } The condition.
TrueBASIC Ch 2 & 3 Sample Problems. What are the errors? (2 total) PRINT "REM" LET REM = 50 reAD currency$, amount DAta "Dollar", 50.
C++ Basics CSci 107. A C++ program //include headers; these are modules that include functions that you may use in your //program; we will almost always.
General Programming Introduction to Computing Science and Programming I.
INTRODUCTION TO PYTHON. 1. The 5 operators in Python are: + - * / %
STREAMS AND FILES OVERVIEW.  Many programs are "data processing" applications  Read the input data  Perform sequence of operations on this data  Write.
Chapter 4 Selection Structures: Making Decisions.
1 Flow of control Sequential Executing instructions one by one, in exact order given Selection Choosing to execute a particular set of statements depending.
Flow of Control Part 1: Selection
How to start Visual Studio 2008 or 2010 (command-line program)
Review for Exam2 Key Ideas 1. Key Ideas: Boolean Operators (2 > 3) || (3 < 29.3) A.True B.False C.Impossible to determine (22 > 3) && (3 > 29.3) A.True.
ORDER OF CONTENT AND INSTRUCTIONS A program in its simplest form usually contains three kinds of activity:  INPUT : The program asks the user for some.
PROBLEM SOLVING & ALGORITHMS CHAPTER 5: CONTROL STRUCTURES - SELECTION.
CHAPTER 8 CONTROL STRUCTURES Prepared by: Lec. Ghader R. Kurdi.
1 09/20/04CS150 Introduction to Computer Science 1 Let ’ s all Repeat Together.
What does C store? >>A = [1 2 3] >>B = [1 1] >>[C,D]=meshgrid(A,B) c) a) d) b)
Conditionals CS 103 February 16, Blast from the Past: C14 Dating Problem Statement: Calculate the age of a fossil from its C-14 radioactivity Problem.
MULTIPLE ALTERNATIVES IF… THEN… ELSEIF SELECT CASE.
CHAPTER#3 PART1 STRUCTURED PROGRAM DEVELOPMENT IN C++ 2 nd semester King Saud University College of Applied studies and Community Service Csc.
Programming, an introduction to Pascal
CS161 Topic #16 1 Today in CS161 Lecture #16 Prepare for the Final Reviewing all Topics this term Variables If Statements Loops (do while, while, for)
Advanced Work with Embedded and Summative Assessment Dr. Steve Broskoske Misericordia University EDU 533 Computer-based Education.
Agenda Basic Logic Purpose if statement if / else statement
Intro to Nested Looping Intro to Computer Science CS1510 Dr. Sarah Diesburg.
Intro to Nested Looping Intro to Computer Science CS1510 Dr. Sarah Diesburg.
The IF-statements 31-Jan-2005 Venkatesh Ramamoorthy.
Introduction to Engineering MATLAB - 13 Agenda Conditional statements  If – end  If – else – end  if – elseif – else - end.
Lecture 2 Conditional Statement. chcslonline.org Conditional Statements in PHP Conditional Statements are used for decision making. Different actions.
Assignment statement and Arithmetic operation 1 The major part of data processing.
Chapter#3 Part1 Structured Program Development in C++
Using variable Variables are used to store values.
1 Agenda If Statement True/False Logical Operators Nested If / Switch Exercises & Misc.
Creating a mystic meg program A simple program asking the user questions and using their answers to build up a fortune telling in a list.
The Hashemite University Computer Engineering Department
© The McGraw-Hill Companies, 2006 Chapter 3 Iteration.
Topics: Selection Statements. Processing Involving Selecting Instructions An instruction that allows deviation and selection to take place uses the ‘IF’
Algorithms and Pseudocode
Programming. Exam Validation 1-10 Technical words such as Method of validation Do not use “Something”.
GCSE Computing: Programming GCSE Programming Remembering Python.
1 for – while – switch ผศ. ดร. อนันต์ ผลเพิ่ม Anan Phonphoem
Practice Programming Exam 1 Review: Part 2 1. Programming Example Bags Fly Fee!!! 2 XYZ is a commercial airline that asked you to create a MATLAB program.
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.
Selection Using IF THEN ELSE CASE Introducing Loops.
More on conditional statements. Conditionals In some situations the typical if-else statements may become cumbersome Depending on the situation, there.
Select Case Blocks School of Business Eastern Illinois University © Abdou Illia, Spring 2003 (Week 8, Monday 3/03/2003)
 Very often when you write code, you want to perform different actions for different decisions. You can use conditional statements in your code to do.
Formatting Output.
SELECTION STATEMENTS (1)
Control Statement Examples
Please use speaker notes for additional information!
In Class Programming BIS1523 – Lecture 11.
Python programming exercise
Basic Lessons 5 & 6 Mr. Kalmes.
Repetition (While Loop) LAB 9
C++ Basics CSci 107. A C++ program //include headers; these are modules that include functions that you may use in your //program; we will almost always.
CA Review 3b (Part 2).
Lecture 8 – Practice Exam
Presentation transcript:

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 < 10 THEN PRINT "Happy Meal" ELSEIF age < 18 PRINT "Ice Cream" ELSE THEN PRINT "Parfait" END IF

What are the errors? (4 total) INPUT age IF age > 7 THEN PRINT "rollercoaster" ELSE PRINT "ferris wheel" IF age < 10 THEN PRINT "Happy Meal" ELSEIF age < 18 THEN PRINT "Ice Cream" ELSE THEN PRINT "Parfait" END IF END 1.Single line IF-ELSE must all be on one line 2.ELSEIF needs a THEN after condition 3.ELSE does not need a THEN 4.Must have an END statement

What is the output? LET x = 10 LET y = 12 IF x > / 10 THEN PRINT "1" IF x > ( ) / 10 THEN PRINT "2" IF x > ( / 10) THEN PRINT "3" IF NOT x > 10 THEN PRINT "4" IF x > y OR y > x THEN PRINT "5" IF NOT x > y OR NOT y > x THEN PRINT "6" END

What is the output? LET x = 10 LET y = 12 IF x > / 10 THEN PRINT "1" IF x > ( ) / 10 THEN PRINT "2" IF x > ( / 10) THEN PRINT "3" IF NOT x > 10 THEN PRINT "4" IF x > y OR y > x THEN PRINT "5" IF NOT x > y OR NOT y > x THEN PRINT "6" END

What is the output? LET x = 14 SELECT CASE x CASE 10 TO 20, 25 TO 35 PRINT "A" CASE 10 TO 20 PRINT "B" CASE ELSE PRINT "C" END SELECT END

What is the output? LET x = 14 SELECT CASE x CASE 10 TO 20, 25 TO 35 PRINT "A" CASE 10 TO 20 PRINT "B" CASE ELSE PRINT "C" END SELECT END A

What are the errors? (4 total) DATA 12 READ x PRINT IF (x < 17 AND IS NOT 13) THEN PRINT "Okay" READ y IF (y > 8) THEN PRINT "Not Okay" ELSE PRINT "Really Bad" DATA 14, 15 READ z, m IF (z z) PRINT "Error" END

What are the errors? (4 total) DATA 12 READ x PRINT IF (x 13) THEN PRINT "Okay" READ y IF (y > 8) THEN PRINT "Not Okay " ELSE PRINT "Really Bad" DATA 14, 15, 16 READ z, m IF (z z) THEN PRINT "Error" END 1.“IS NOT” is not valid syntax in an IF condition 2.Single line IF-ELSE must all be on one line 3.Insufficient Data 4.IF statement must be followed by THEN

Write a One Line TrueBASIC Statement for each of the Following Commands Ask the user for his/her name Print winner when the team is Rutgers, otherwise print loser Calculate dollars spent as quantity times price

Write a One Line TrueBASIC Statement for each of the Following Commands Ask the user for his/her name INPUT PROMPT "What is your name? ": name$ Print winner when the team is Rutgers, otherwise print loser IF(team$ = "Rutgers") THEN PRINT "winner" ELSE PRINT "Loser" Calculate dollars spent as quantity times price LET dollars_spent = quantity * price

Write a One Line TrueBASIC Statement for each of the Following Commands Get data (not from user) for 3 car name variables Provide the values for 3 car names Display to the user the contents of the num variable, but put three tabs in front

Write a One Line TrueBASIC Statement for each of the Following Commands Get data (not from user) for 3 car name variables READ car1$, car2$, car3$ Provide the values for 3 car names DATA "Grand Prix", "Camaro", "Mustang" Display to the user the contents of the num variable, but put three tabs in front PRINT,,,num