Writing Program Code in BASIC Write a program to prompt for and accept values into TWO variables, numx and numy. The program should square the value stored.

Slides:



Advertisements
Similar presentations
Problem Solving INFORMATION TECHNOLOGY
Advertisements

Andrew C. Samuels, Information Technology Specialist Trainer c/o Ministry of Education Mona High School, Kingston, Jamaica 1 Problem Solving Section 2:
CMSC 104, Version 9/011 Arithmetic Operators Topics Arithmetic Operators Operator Precedence Evaluating Arithmetic Expressions In-class Project Incremental.
PSEUDOCODE & FLOW CHART
 Control structures  Algorithm & flowchart  If statements  While statements.
CS107 Introduction to Computer Science Loops. Instructions Pseudocode Assign values to variables using basic arithmetic operations x = 3 y = x/10 z =
What is an algorithm? Informally: An Algorithm is a step by step method for solving a problem. It’s purpose is to break a larger task down so that each.
11.3 Function Prototypes A Function Prototype contains the function’s return type, name and parameter list Writing the function prototype is “declaring”
CS107 Introduction to Computer Science Lecture 5, 6 An Introduction to Algorithms: List variables.
Computer Science 1620 Programming & Problem Solving.
©TheMcGraw-Hill Companies, Inc. Permission required for reproduction or display. Chapter 6: Repetition  Some additional operators increment and decrement.
Practice for Midterm 1. Practice problems These slides have six programming problems for in-class practice There are an additional seven programming problems.
CS 1400 Jan 10, What is it? Computer Science is the art and science of writing programs –Users use programs –Programmers create these programs A.
Chapter 1 Pseudocode & Flowcharts
Equations Positive/Neg Integers GeometryPercent
Computer Science 1000 Spreadsheets II Permission to redistribute these slides is strictly prohibited without permission.
REPETITION STRUCTURES. Topics Introduction to Repetition Structures The while Loop: a Condition- Controlled Loop The for Loop: a Count-Controlled Loop.
C programming: Variables, Expressions part II. Data Types of Arithmetic Expressions Relational Expressions Logical Expressions Multiple Assignments Compound.
© Copyright 1992–2005 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. Looping Exercises Deciding Which Loop to Use At this.
CPSC 171 Introduction to Computer Science 3 Levels of Understanding Algorithms More Algorithm Discovery and Design.
Loop Exercise 1 Suppose that you want to take out a loan for $10,000, with 18% APR, and you're willing to make payments of $1,200/month. How long will.
Looping While-continue.
Copyright © 2012 Pearson Education, Inc. Publishing as Pearson Addison-Wesley C H A P T E R 6 Value- Returning Functions and Modules.
Arithmetic Operators Topics Arithmetic Operators Operator Precedence
Vectors and Matrices In MATLAB a vector can be defined as row vector or as a column vector. A vector of length n can be visualized as matrix of size 1xn.
Warm-Up Exercises 1. Right rectangular prism, side lengths 8 in., 5 in., and 10 in. 2. Right cone, radius 3 m, height 4 m ANSWER 340 in. 2 ; 400 in. 3.
How to start Visual Studio 2008 or 2010 (command-line program)
Coding Design Tools Rachel Gauci. What are Coding Design Tools? IPO charts (Input Process Output) Input- Make a list of what data is required (this generally.
CSCI N341: Client-Side Web Programming Copyright ©2004  Department of Computer & Information Science Writing JavaScript Functions.
PROBLEM SOLVING & ALGORITHMS CHAPTER 5: CONTROL STRUCTURES - SELECTION.
Writing JavaScript Functions. Goals By the end of this unit, you should understand … How to breakdown applications into individual, re-usable modules.
Unit 2 – Algorithms & Pseudocode. Algorithms Computer problems solved by executing series of action in order Procedure –The Actions to execute –The Order.
Variables. Todays Lesson  In todays lesson you are going to:  Learn to use variables  Learn to ask for user input  Learn to save the users response.
Counter-Controlled Loops CSIS 1595: Fundamentals of Programming and Problem Solving 1.
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)
© Copyright 1992–2005 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. Tutorial 7 – Class Average Application: Introducing.
CSCI-100 Introduction to Computing
Intro to Nested Looping Intro to Computer Science CS1510 Dr. Sarah Diesburg.
1 Programming 2 Overview of Programming 1. Write the equations in C++ notation : a) R =   a + b  24  2 a  b) W = a 12 + b 2 – 2abcos(y) 2a.
CMSC 104, Version 8/061L10ArithmeticOps.ppt Arithmetic Operators Topics Arithmetic Operators Operator Precedence Evaluating Arithmetic Expressions In-class.
Holt McDougal Algebra Solving Quadratic Inequalities 2-7 Solving Quadratic Inequalities Holt Algebra 2 Warm Up Warm Up Lesson Presentation Lesson.
Copyright © 2012 Pearson Education, Inc. Publishing as Pearson Addison-Wesley C H A P T E R 5 Repetition Structures.
Agenda Perform Quiz #1 (20 minutes) Loops –Introduction / Purpose –while loops Structure / Examples involving a while loop –do/while loops Structure /
CSC 1010 Programming for All Lecture 4 Loops Some material based on material from Marty Stepp, Instructor, University of Washington.
Arrays. The array data structure Array is a collection of elements, that have the same data type Integers (int) Floating point numbers (float, double)
Algorithm Discovery and Design Objectives: Interpret pseudocode Write pseudocode, using the three types of operations: * sequential (steps in order written)
INTRODUCTION TO PROGRAMMING. Program Development Life Cycle The program development life cycle is a model that describes the stages involved in a program.
Exercise 1 #include int main() { printf(“Hello C Programming!\n”); return 0; } 1.Run your Visual Studio 2008 or Create a new “project” and add.
Intro to Loops 1.General Knowledge 2.Two Types of Loops 3.The WHILE loop 1.
CS 141 Computer Programming 1 Branching Statements.
Think First, Code Second Understand the problem Work out step by step procedure for solving the problem (algorithm) top down design and stepwise refinement.
Tutorial 9 Iteration. Reminder Assignment 8 is due Wednesday.
Computer Science 1000 Algorithms III. Multiple Inputs suppose I ask you to write a program that computes the area of a rectangle area = length * width.
For Wednesday No reading No homework. Exam 1 Wednesday night STV pm Sign up if you need to take a make-up (after clearing it with me)
General Condition Loop A general condition loop just loops while some condition remains true. Note that the body of the loop should (eventually) change.
CS 240 Computer Programming 1
Exercise 2 : Using for loop Repetition (loop) (1)control variable initialization (2)Test Conditon (3)Modification of control variable value order : (1)
Exercise : Write a program that print the final price of purchase at a store where everything costs exactly one dollar. Ask for the number of items purchased.
while Repetition Structure
Check your understanding!
Chapter 4: Control Structures
Lecture 2 Introduction to Programming
CISC101 Reminders Quiz 1 grading underway Next Quiz, next week.
Intro to Nested Looping
Chapter 5: Control Structure
Intro to Nested Looping
Programming Concepts and Database
GCSE Computing Mini Assignment.
H446 Computer Science.
Presentation transcript:

Writing Program Code in BASIC Write a program to prompt for and accept values into TWO variables, numx and numy. The program should square the value stored in numx than interchange the values in TWO variables and print these values.

Writing Program Code in BASIC Check YOUR understanding. Write a program which prompts the user to enter the price of an item and which calculates and prints the new price after a discount of 12%.

Writing Program Code in BASIC Whilst you’re in the mood … Write a program to accept the radius of a circle, r, and compute and print its circumference based on the formula: 2πr. The value of π is 3.142

Writing Program Code in BASIC Write a program to read in TWO integers into variables A and B. Print these values. The program should store the smaller in A and the larger in B, and then print A and B. Print the value obtained by dividing the LARGER number by the SMALLER number. You may assume that the numbers are not equal. Write a program to read in TWO integers into variables A and B. Print these values. The program should store the smaller in A and the larger in B, and then print A and B. Print the value obtained by dividing the LARGER number by the SMALLER number. You may assume that the numbers are not equal.

Writing Program Code in BASIC Write a structured algorithm to accept values in TWO variables A & B. Print the product of these two variables if it is greater than or equal to 100, otherwise print “SORRY – not enough” Write a structured algorithm to accept values in TWO variables A & B. Print the product of these two variables if it is greater than or equal to 100, otherwise print “SORRY – not enough”

Writing Program Code in BASIC Check YOUR understanding. Write a program in BASIC to read in the values of two numbers, find their sum, then their product. Check whether the product is bigger than the sum. If the product is bigger, it must print a message to say so, and if the product is not bigger it must print a message saying that the product is not bigger. © CXC – June 2003

Writing Program Code in BASIC Using COUNT-CONTROLLED LOOPS Write a program in BASIC to print the 2 times multiplication table. Table should have the format: 2 x 1 = 2 2 x 2 = x 12 = 24

Writing Program Code in BASIC Using COUNT-CONTROLLED LOOPS Write a program using BASIC to find the sum of M numbers where the user supplies the value of M and types the numbers, in response to the prompts generated by the program.

Writing Program Code in BASIC Using COUNT-CONTROLLED LOOPS Try this one. Write a program in BASIC to do the following: i. Announce (with a printed statement) that it will find the volumes of sets of boxes ii. Ask how many boxes there are iii. For EACH box, ask for the length, width, and height iv. Compute the volume of EACH box. If the values of length, width and height are all greater than zero, then print the volume. v. When finished with all the boxes, print the message: “Volumes have been found”.

Writing Program Code in BASIC Using CONDITION-CONTROLLED LOOPS Write a program in BASIC to accept and print a positive integer.

Writing Program Code in BASIC Write a program to read a positive integer N and find the average of all even numbers between 1 and N inclusive. Perform any necessary validation. Write a program to read a positive integer N and find the average of all even numbers between 1 and N inclusive. Perform any necessary validation.