1 E0001 Computers in Engineering Built in Functions.

Slides:



Advertisements
Similar presentations
What Does This Program Do?
Advertisements

Computer Programming w/ Eng. Applications
P1PMF Split1 QBASIC. P1PMF Split2QBasic Command Prompt Will launch the emulator DOS operating system? Press Alt + Enter to display the widescreen.
Intro to Python Welcome to the Wonderful world of GIS programing!
VB Built-in Functions School of Business Eastern Illinois University © Abdou Illia, Spring 2003 (Week 5, Monday 2/10/03)
Mark Dixon, SoCCE SOFT 131Page 1 04 – Information Processing: Data-types, Variables, Operators & Functions.
Introduction to Computing Dr. Nadeem A Khan. Lecture 6.
Mark Dixon, SoCCE SOFT 131Page 1 05 – Information Processing: Data-types, Variables, Operators & Functions.
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.
Database Management Review for Final (Part 1) School of Business Eastern Illinois University © Abdou Illia, Spring 2003 (Week 15, Wednesday 4/30/2003)
Expressions and Interactivity Chapter 3. 2 The cin Object Standard input object Like cout, requires iostream file Used to read input from keyboard Often.
Python Programming Fundamentals
EG280 - CS for Engineers Chapter 2, Introduction to C Part I Topics: Program structure Constants and variables Assignment Statements Standard input and.
 2003 Prentice Hall, Inc. All rights reserved. CHAPTER 3 JavaScript 1.
E0001 Computers in Engineering
General Programming Introduction to Computing Science and Programming I.
E0001 Computers in Engineering Built in Functions.
Computer Science 111 Fundamentals of Programming I Basic Program Elements.
PYTHON: PART 2 Catherine and Annie. VARIABLES  That last program was a little simple. You probably want something a little more challenging.  Let’s.
Chapter 3 Processing and Interactive Input. 2 Assignment  The general syntax for an assignment statement is variable = operand; The operand to the right.
Copyright © 2009 Pearson Education, Inc. Publishing as Pearson Addison-Wesley STARTING OUT WITH Python Python First Edition by Tony Gaddis Chapter 2 Input,
E0001 Computers in Engineering Procedures: subprograms and functions.
 2003 Prentice Hall, Inc. All rights reserved. CHAPTER 3 JavaScript 1.
Computer Programming TCP1224 Chapter 4 Variables, Constants, and Arithmetic Operators.
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.
Data & Data Types & Simple Math Operation 1 Data and Data Type Standard I/O Simple Math operation.
How to start Visual Studio 2008 or 2010 (command-line program)
Week 3 Let's review! Fundamental data types List-directed input/output.
Control Structures (A) Topics to cover here: Introduction to Control Structures in the algorithmic language Sequencing.
Neal Stublen What's a class?  A class is comprised of a set of data and the actions taken on that data  Each action is represented.
Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Extended Prelude to Programming Concepts & Design, 3/e by Stewart Venit and.
Introduction to Computer Programming
CS Class 08 Today  Exercises  Nested loops  for statement  Built-in functions Announcements  Homework #3, group solution to in-class.
A first program 1. #include 2. using namespace std; 3. int main() { 4. cout
‘Tirgul’ # 2 Enterprise Development Using Visual Basic 6.0 Autumn 2002 Tirgul #2.
Expressions and Interactivity. 3.1 The cin Object.
CSC 1010 Programming for All Lecture 3 Useful Python Elements for Designing Programs Some material based on material from Marty Stepp, Instructor, University.
CHAPTER 2 PROBLEM SOLVING USING C++ 1 C++ Programming PEG200/Saidatul Rahah.
Chapter 3 Numerical Data. Objectives After you have read and studied this chapter, you should be able to Select proper types for numerical data. Write.
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.
Calculator Program Explained by Arafa Hamed. First Designing The Interface Ask yourself how many places are there that will be used to input numbers?
Assignments. Assignment 1 Write a program to calculate the current equation Where p is the period of pendulum in seconds, g=980 cm/sec 2 (acceleration),
 2007 Pearson Education, Inc. All rights reserved. A Simple C Program 1 /* ************************************************* *** Program: hello_world.
Variables in C Topics  Naming Variables  Declaring Variables  Using Variables  The Assignment Statement Reading  Sections
Variables in C Topics  Naming Variables  Declaring Variables  Using Variables  The Assignment Statement Reading  Sections
Chapter 2 Excel Fundamentals Logical IF (Decision) Statements Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
CMSC 104, Version 8/061L09VariablesInC.ppt Variables in C Topics Naming Variables Declaring Variables Using Variables The Assignment Statement Reading.
CSx 4091 – Python Programming Spring 2013 Lecture L2 – Introduction to Python Page 1 Help: To get help, type in the following in the interpreter: Welcome.
Sudeshna Sarkar, IIT Kharagpur 1 Programming and Data Structure Sudeshna Sarkar Lecture 3.
Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Extended Prelude to Programming Concepts & Design, 3/e by Stewart Venit and.
A Sample Program #include using namespace std; int main(void) { cout
1 C Syntax and Semantics Dr. Sherif Mohamed Tawfik Lecture Two.
 What Does This Program Do? ACSL.  Frequently one must use or modify sections of another programmer’s code.  It is essential to be able to read and.
October 15, 2013 Welcome! We will begin shortly..
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;
CS 115 Lecture 5 Math library; building a project Taken from notes by Dr. Neil Moore.
L131 Assignment Operators Topics Increment and Decrement Operators Assignment Operators Debugging Tips rand( ) math library functions Reading Sections.
Introduction to Programming
Introduction to Programming
Computing Fundamentals
Introduction to Programming
Assignment Operators Topics Increment and Decrement Operators
Sub Procedures and Functions
Introduction to Programming
Assignment Operators Topics Increment and Decrement Operators
Introduction to Programming
Assignment Operators Topics Increment and Decrement Operators
Class code for pythonroom.com cchsp2cs
def-ining a function A function as an execution control structure
Presentation transcript:

1 E0001 Computers in Engineering Built in Functions

2 General Notes l Check when the first assignment is due! l Have you thought about it? l Although not due it should be completed by now!!!! l Assignments may be “posted”on the 4th floor Z block

3 What is the outcome? READ studnumber, names$ DATA 12345, “smith” total$ = “6” PRINT total$ + 4

4 Readings and Exercises l Schneider Section 3.4 p l Schneider Practice Problems 3.4 p 78; programming problems #’s 57, 60, 62, 66, 68

5 Rem statements l Rem short for REMARK l used for adding comments to code l useful for the programmer, not the user l non executable line l Two ways of adding comments –REM –‘

6 Examples REM this line is a comment REM This program will calculate…. REM This program was written by…. INPUT r,b,h‘radius, base, height READ n$, no$‘name, number

7 Numeric Functions l covers common numeric and trigonometric terms –square root - SQR(x) –SIN(angle), COS(angle), TAN(angle) l BEWARE - (angle) must be in RADIANS –LOG (x) l see handout for more examples

8 Examples of Numeric Functions l SQR (x) - square root of x where x is –variable - given a value by the program or the user –arithmetic operation - (6-4)/360*12 l ABS - absolute value –ABS(-3) = 3; ABS(7) = 7 –ABS(SQR(CINT(x)))

9 String Functions l allows examining strings or parts; combining strings l allows string comparisons using, = (relational operators)

10 Examples of String Functions l LEN(s) - s is known as the argument –returns the length of the argument i.e. the number of characters contained in the argument –blanks are counted as characters –LEN(“John and Mary”) = 13 –Z$ = “John and Mary”: LEN(Z$) = 13 –IF LEN(Z$) = 20 THEN PRINT “HELLO”

11 l LEFT$(x$, n) - x$ is any string; n is an integer from 0 to LEN(x$) –x$ = “John and Mary” –PRINT LEFT$(x$,4) - gives the output John l see also MID$(x$,n,m) and RIGHT$(x$,n) l LCASE$(X$); UCASE$(X$); INSTR(n,X$,Y$) l VAL(X$) - converts a string whose contents represent a number to its numerical form. –ignores leading blanks –converts a string up to its first nonnumerical character into its numerical value.

12 Built-in Functions l prewritten “subroutine” that does one operation l returns ONE value only l designed to manipulate both numerical and string data l cover common calculations

13 The period P of a pendulum of length L and maximum displacement angle  is given by the formula P = write a program that requests as input the length and maximum angle of displacement, and displays the period of the pendulum Problem

14 Tutorial 1. What will be the contents of x after the following statement is executed? LET x = SQR((9 + 7) / ( 4 * 2) + 2) 2. Suppose num = What is the output? LET num = INT(100 * num +.5) / 100 PRINT num

15 3. What output is generated by the following statements (show the output EXACTLY as it would appear on the screen)? PRINT SQR (3^2 + 4^2) PRINT MID$ ("Milkshake", 5, 5) PRINT UCASE$ ("123jump") 5 shake 123JUMP try this for yourself

16 4. The following statements are valid. (T/F) LET H$ = "Hello" LET a$ = INSTR(H$, 3) 5. Given the data in the variable y$ shown below, which of the following statements will assign the value ALL to x$? LET y$ = "WHEN ALL ELSE FAILS, READ THE DIRECTIONS" (a) LET x$ = MID$(y$, 6, 3) (b) LET x$ = INSTR(6, y$, "ALL") (c) LET x$ = LEFT$(y$, 3) (d) LET x$ = MIDDLE$(y$, 6, 3) (e) LET x$ = RIGHT$(y$, 8)

17 6. What will be displayed when the following program is executed? LET a$ = "THE WHOLE" LET b$ = "PART" LET c$ = MID$(a$, SQR(4), LEN(b$)) PRINT c$ END

18 The End

19 Now change the program to include INPUT statements DIM radius AS integer DIM pi AS double DIM circ AS double radius = 3.2 pi = 22/7 circ = 2*pi*radius PRINT radius,pi,circ DIM radius AS integer, pi AS double, circ AS double pi = 22/7 INPUT radius circ = 2*pi*radius PRINT”radius = “;radius PRINT”pi = “;pi PRINT “circumference is“;circ