D.L. Kreher. Department of Mathematical Sciences. Michigan Technological University. and. D.R. Stinson

Size: px
Start display at page:

Download "D.L. Kreher. Department of Mathematical Sciences. Michigan Technological University. and. D.R. Stinson"

Transcription

1 Pseucode: A L A T E X Style File for Displaying Algorithms D.L. Kreher Department of Mathematical Sciences Michigan Technological University Houghton, MI kreher@mtu.edu and D.R. Stinson Department of Combinatorics and Optimization University of Waterloo Waterloo ON, N2L 3G1 dstinson@uwaterloo.ca September 3, Introduction This paper describes a LATEX environment named pseucode that can be used for describing algorithms in pseucode form. This is the style used in our textbook Combinatorial Algorithms: Generation, Enumeration and Search [2]. The style le pseucode.sty is available for free wnloading from the web page This package is quite easy to use, and allows algorithms to be described in a LATEX cument using a natural Pascal-like syntax. In the remaining sections of this note, we describe how to use the pseucode environment and we present some examples. Readers familiar with LATEX (see [3]) should be able to easily customize the style le to include additional desired features. The pseucode environment requires the fancybox package by Timothy Van Zandt. This package is described in Section of [1]. Other environments for describing algorithms include alg, algorithmic, newalg 1

2 and program. These style les, as well fancybox, are all available from the CTAN web site 2 The pseucode Environment Within the pseucode environment, a number of commands for popular algorithmic constructs are available. In general, the commands provided can be nested to describe quite complex algorithms. The pseucode environment is invoked as follows: \begin{pseucode}{<name>}{<parameters>} pseucode constructs \end{pseucode} The argument <Name> is the name of the algorithm, and <Parameters> is a list of parameters for the algorithm. For example, the commands \begin{pseucode}{celsiustofahrenheit}{c} f \GETS {9c/5} + 32\\ \RETURN{f} \end{pseucode} produce the following output when included in a LATEX cument: Algorithm 2.1: CelsiusToFahrenheit(c) f 9c= return (f) Notice that the command \GETS produces a left arrow, which we use to indicate an assignment of a variable. The user could use instead some other symbol, if desired. For example, \GETS could be replaced by =, as is ne in the \C" programming language. 2.1 The begin-end Construct To form compound statements from simple statements, the begin-end construct is used as follows: some statement\\ another statement\\ yet another statement 2

3 This generates the following: 8 < : some statement another statement yet another statement The eect of this construct is to group a collection of statements using a left brace bracket of the appropriate size. In the sections that follow we will use the notation <stmt> to indicate a simple statement or a compound statement. Note that the contents of statements are typeset in math mode. Therefore, non-math mode text must be enclosed in an \mbox{}. Observe that the uble backslash \\ plays the same role as the semicolon in Pascal, i.e., it is used to separate statements, and should never appear before. 2.2 The if-then-else Construct The if-then-else construct takes various forms, such as the following: \IF <condition> \THEN <stmt> \IF <condition> \THEN <stmt> \ELSE <stmt> \IF <condition> \THEN <stmt> \ELSEIF <stmt> \THEN <stmt> Note that there is no limit placed on the number of \ELSEIFs that may be used in an if-then-else construct. For example, the commands: \IF some condition is true \THEN some statement\\ another statement\\ yet another statement \ELSEIF some other condition is true \THEN some statement\\ another statement\\ yet another statement \ELSEIF some even more bizarre condition is met \THEN something else \ELSE the default actions 3

4 would produce the following output: 8 if some condition is true < some statement then another statement : yet another statement else if8 some other condition is true < some statement then another statement : yet another statement else if some even more bizarre condition is met then something else else the default actions 2.3 The for Loop The for loop takes the following forms: \FOR <var> \GETS <lower> \FOR <var> \GETS <upper> \FOREACH <condition> \DO For example, \TO <upper> \DO <stmt> \DOWNTO <lower> \DO <stmt> <stmt> \FOR i \GETS 0 \TO 10 \DO some processing produces for i 0 to 10 some processing and \FOREACH x \in \mathcal{s} some processing \DO produces for each x 2 S some processing 2.4 The while Loop The while loop takes the following form: \WHILE <condition> \DO <stmt> For example, 4

5 \WHILE some condition holds \DO some processing produces while some condition holds some processing 2.5 The repeat-until Loop The repeat-until loop takes the following form: \REPEAT <stmt> \UNTIL <condition> For example, \REPEAT some processing \UNTIL some condition is met produces repeat some processing until some condition is met 2.6 Main Programs and Procedures We can describe a main program that calls one (or more) procedures as follows: \begin{pseucode}{<name>}{<parameters>} \PROCEDURE{<ProcedureName>}{<ProcedureParameters>} some stuff PROCEDURE \MAIN some stuff\\ \CALL{<ProcedureName>}{<ActualParameters}>\\ more stuff MAIN \end{pseucode} Here is a simple example to illustrate the use of a main program calling a procedure. The commands 5

6 \begin{pseucode}{temperaturetable}{lower, upper} \PROCEDURE{CelsiusToFahrenheit}{c} f \GETS {9c/5} + 32\\ \RETURN{f} PROCEDURE \MAIN x \GETS lower \\ \WHILE x \leq upper \DO \OUTPUT{x, \CALL{CelsiusToFahrenheit}{x}}\\ x \GETS x+1 MAIN \end{pseucode} produce the following output: Algorithm 2.8: TemperatureTable(lower; upper) procedure CelsiusToFahrenheit(c) f 9c= return (f) main x lower while x upper output (x; CelsiusToFahrenheit(x)) x x Comments A comment statement may be inserted in an algorithm using the following command: \COMMENT{<stmt>} For example, the commands A \GETS B\\ \COMMENT{Now increment the value of $A$}\\ A \GETS A+1 produce the output 6

7 A B comment: Now increment the value of A A A + 1 Note that comments are assumed to be text. Thus, in order to include mathematical expressions in a comment, math mode must be used explicitly. 2.8 Other Predened Keywords Several other predened keywords are available. We summarize their usage in Table 1. Table 1: Other Predened Keywords command \LOCAL{list of variables} \GLOBAL{list of variables} \EXTERNAL{list of procedures} \RETURN{list of values} \OUTPUT{list of values} \EXIT \AND \OR \NOT \TRUE \FALSE \GETS output local list of variables global list of variables external list of procedures return (list of values) output (list of values) exit and or not true false Also note that all of the keywords \IF, \WHILE, \CALL{}{}, \NOT, etc. are available for use outside of the pseucode environment, but they must be input in math mode. For example, generates The $\WHILE$ loop is our friend. The while loop is our friend. 2.9 Statement Numbering Statements can be numbered and given a reference key so that they can be referenced in a LATEX cument using a \ref{} command (see section 4.2 of [3]). This is ne as follows: 7

8 \STMTNUM{<space>}{<key>} The argument <space> is the amount of space to be left between the text and the statement number. This is a length that is specied by the user, and generally will require some experimentation in order for it to look nice. The argument <key> is the reference key used in the LaTeX \ref{} command to refer to the given statement. The default numbering for statements is arabic. However, it can be changed by a suitable \renewcommand{}. An example is provided in the next section. 3 An example The following example demonstrates the use of the pseucode environment to describe a complete algorithm, the familiar \mergesort" algorithm. The LATEX input \renewcommand{\thepseunum}{\roman{pseunum}} \begin{pseucode}{mergesort}{n,x} \label{mergesort} \COMMENT{Sort the array $X$ of length $n$}\\ \IF n=2 \THEN \IF X[0]>X[1] \THEN T \GETS X[0]\\ X[0]\GETS X[1]\\ X[1]\GETS T \ELSEIF n>2 \THEN m\gets \lfloor n/2 \rfloor\\ \FOR i\gets 0 \TO m-1 \DO A[i] \GETS X[i]\\ \FOR i\gets m \TO n-1 \DO B[i] \GETS X[i]\\ \COMMENT{Now sort the subarrays $A$ and $B$}\\ \CALL{MergeSort}{m,A}\\ \CALL{MergeSort}{n-m,B}\\ i\gets 0\\ j\gets 0\\ \FOR k \GETS 0 \TO n-1 \DO \IF A[i] \leq B[j] \THEN 8

9 X[k]\GETS A[i] \STMTNUM{1in}{st.1}\\ i\gets i+1 \ELSE X[k]\GETS B[j] \STMTNUM{1.03in}{st.2}\\ j\gets j+1 \end{pseucode} produces the following output: Algorithm 3.1: MergeSort(n; X) comment: Sort the array X of length n 8 if n = 2 if X[0] > 8X[1] < T X[0] then then X[0] X[1] : X[1] T else if n > 2 8 m bn=2c for i 0 to m? 1 A[i] X[i] for i m to n? 1 B[i] X[i] comment: Now sort the subarrays A and B then MergeSort(m; A) MergeSort(n? m; B) i 0 j 0 for k 8 0 to n? 1 if A[i] B[j] X[k] A[i] (i) then i i + 1 X[k] B[j] (ii) else j j + 1 The counter pseunum keeps track of the statement numbers. The style of the counter values can be changed using the method described in Section 6.3 of [3]. For example, we used the command 9

10 \renewcommand{\thepseunum}{\roman{pseunum}} in our example so that statements were numbered with lowercase Roman numerals. We also assigned a label to the algorithm using the \label{} command that is described in Section 4.2 of [3]. Finally, by trial and error, we determined spacing so that the statement numbers would be vertically aligned. We now give an example of how the numbered statements in the above algorithm can be referenced in a LATEXcument. The commands On lines (\ref{st.1}) and (\ref{st.2}) of Algorithm \ref{mergesort}, we determine the $k$th element of the sorted array. produce the following output: On lines (i) and (ii) of Algorithm 3.1, we determine the kth element of the sorted array. 4 Framing The pseucode environment also has an optional parameter, <frame>. The complete form of the pseucode environment is \begin{pseucode}[<frame>]{<name>}{<parameters>} pseucode constructs \end{pseucode} The possible values of <frame> are: shawbox ublebox ovalbox Ovalbox framebox plain ruled display The values ending with \box" draw various types of frames around the algorithm. The value plain is the default and adds no frame to the algorithm. The value display is used for displaying sections of code without the algorithm name or parameters. Here are some examples with input: \begin{pseucode}[<frame>]{squareandmultiply}{x,b,n} \COMMENT{ Compute $x^b \pmod{n}$}\\ z\gets 1\\ \WHILE b > 0 \DO z \GETS z^2 \pmod{n} \\ \IF b\mbox{ is odd} 10

11 \THEN z \GETS z \ct x \pmod{n} \\ b \GETS \CALL{ShiftRight}{b} \\ \RETURN{z} \end{pseucode} where we give <frame> each of the values described above. When <frame> is shawbox we obtain: Algorithm 4.1: SquareAndMultiply(x; b; n) comment: Compute x b (mod n) z 1 while8 b > 0 z z 2 (mod n) return (z) When <frame> is ublebox we obtain: Algorithm 4.2: SquareAndMultiply(x; b; n) comment: Compute x b (mod n) z 1 while8 b > 0 z z 2 (mod n) return (z) When <frame> is ovalbox we obtain: 11

12 Algorithm 4.3: SquareAndMultiply(x; b; n) comment: Compute x b (mod n) z 1 while8 b > 0 z z 2 (mod n) return (z) When <frame> is Ovalbox we obtain: Algorithm 4.4: SquareAndMultiply(x; b; n) comment: Compute x b (mod n) z 1 while8 b > 0 z z 2 (mod n) return (z) When <frame> is framebox we obtain: Algorithm 4.5: SquareAndMultiply(x; b; n) comment: Compute x b (mod n) z 1 while8 b > 0 z z 2 (mod n) return (z) When <frame> is plain or if [<frame>] is omitted we obtain: 12

13 Algorithm 4.6: SquareAndMultiply(x; b; n) comment: Compute x b (mod n) z 1 while8 b > 0 z z 2 (mod n) return (z) When <frame> is ruled we obtain: Algorithm 4.7: SquareAndMultiply(x; b; n) comment: Compute x b (mod n) z 1 while8 b > 0 z z 2 (mod n) return (z) The purpose of the value display is to allow portions of algorithms to be displayed with out the algorithm header. Thus for example to display the section of code in the while loop of the SquareAndMultiply() algorithm one could write \begin{center} \begin{minipage}{2in} \begin{pseucode}[display]{}{} z \GETS z^2 \pmod{n} \\ \IF b\mbox{ is odd} \THEN z \GETS z \ct x \pmod{n}\\ b \GETS \CALL{ShiftRight}{b} \end{pseucode} \end{minipage} \end{center} which would produce the following output: 13

14 z z 2 (mod n) References [1] M. Goossens, F. Mittelbach and A. Samarin, The LA TE XCompanion, Addison-Wesley, [2] D.L. Kreher and D.R. Stinson, Combinatorial Algorithms: Generation, Enumeration and Search, CRC Press, [3] L. Lamport, LATEX, A Document Preparation System, Addison-Wesley,

David Helmbold, October 2005, Revised October 2007

David Helmbold, October 2005, Revised October 2007 Short Intro to LATEX David Helmbold, October 2005, Revised October 2007 Goals: Introduce L A TEX... so you can read/edit L A TEX source... and use manual as reference rather than reading it Outline: 1.

More information

Chapter 2: Functions and Control Structures

Chapter 2: Functions and Control Structures Chapter 2: Functions and Control Structures TRUE/FALSE 1. A function definition contains the lines of code that make up a function. T PTS: 1 REF: 75 2. Functions are placed within parentheses that follow

More information

beginlatex /12/ : page #199

beginlatex /12/ : page #199 beginlatex --- 2018/12/4 --- 23:30 --- page 163 --- #199 7Programmability We ve touched several times on the ability of L A TEX to be reprogrammed. This is one of its central features, and one that still,

More information

Homework # You ll want to use some LaTeX editor to edit and compile your.tex files

Homework # You ll want to use some LaTeX editor to edit and compile your.tex files Homework # 1 What is LaTeX? LaTeX is a document markup language You prepare a (.tex) document, and compile it into a PDF LaTeX helps make your homework pretty (just like this document!) and makes us happy

More information

CS313D: ADVANCED PROGRAMMING LANGUAGE

CS313D: ADVANCED PROGRAMMING LANGUAGE CS313D: ADVANCED PROGRAMMING LANGUAGE Computer Science Department Lecture 3: C# language basics Lecture Contents 2 C# basics Conditions Loops Methods Arrays Dr. Amal Khalifa, Spr 2015 3 Conditions and

More information

LATEX Primer. 1 Introduction (Read Me)

LATEX Primer. 1 Introduction (Read Me) LATEX Primer 1 Introduction (Read Me) This document is intended to be used as a primer. You are welcome to remove the body of the document and use the headers only. If you actually read this document,

More information

LESSON 3. In this lesson you will learn about the conditional and looping constructs that allow you to control the flow of a PHP script.

LESSON 3. In this lesson you will learn about the conditional and looping constructs that allow you to control the flow of a PHP script. LESSON 3 Flow Control In this lesson you will learn about the conditional and looping constructs that allow you to control the flow of a PHP script. In this chapter we ll look at two types of flow control:

More information

DEMO A Language for Practice Implementation Comp 506, Spring 2018

DEMO A Language for Practice Implementation Comp 506, Spring 2018 DEMO A Language for Practice Implementation Comp 506, Spring 2018 1 Purpose This document describes the Demo programming language. Demo was invented for instructional purposes; it has no real use aside

More information

The multicap L A TEX2ε package

The multicap L A TEX2ε package The multicap L A TEX2ε package John Vassilogiorgakis giannis@iris.math.aegean.gr 12th May 2002 Abstract This is a package for formating captions of column figures and column tabular material which cannot

More information

example: name1=jan name2=mike export name1 In this example, name1 is an environmental variable while name2 is a local variable.

example: name1=jan name2=mike export name1 In this example, name1 is an environmental variable while name2 is a local variable. Bourne Shell Programming Variables - creating and assigning variables Bourne shell use the set and unset to create and assign values to variables or typing the variable name, an equal sign and the value

More information

L A TEX Class Holiday Inn Fisherman s Wharf San Francisco, CA July Cheryl Ponchin Sue DeMerritt

L A TEX Class Holiday Inn Fisherman s Wharf San Francisco, CA July Cheryl Ponchin Sue DeMerritt L A TEX Class Holiday Inn Fisherman s Wharf San Francisco, CA July 2004 Cheryl Ponchin Sue DeMerritt i Contents 1 Table of Contents 1 Youmayneedtoaddextrainformation... 1 Adding to Contents 1 2 Make an

More information

Professor Peter Cheung EEE, Imperial College

Professor Peter Cheung EEE, Imperial College 1/1 1/2 Professor Peter Cheung EEE, Imperial College In this lecture, we take an overview of the course, and briefly review the programming language. The rough guide is not very complete. You should use

More information

How to use abdnthesis.cls

How to use abdnthesis.cls How to use abdnthesis.cls Timothy J. Norman A dissertation submitted in partial fulfilment of the requirements for the degree of Doctor of Philosophy of the University of Aberdeen. Department of Computing

More information

Chapter 4 The If Then Statement

Chapter 4 The If Then Statement The If Then Statement Conditional control structure, also called a decision structure Executes a set of statements when a condition is true The condition is a Boolean expression For example, the statement

More information

Introduction. C provides two styles of flow control:

Introduction. C provides two styles of flow control: Introduction C provides two styles of flow control: Branching Looping Branching is deciding what actions to take and looping is deciding how many times to take a certain action. Branching constructs: if

More information

Working with JavaScript

Working with JavaScript Working with JavaScript Creating a Programmable Web Page for North Pole Novelties 1 Objectives Introducing JavaScript Inserting JavaScript into a Web Page File Writing Output to the Web Page 2 Objectives

More information

Introduction to Python - Part I CNV Lab

Introduction to Python - Part I CNV Lab Introduction to Python - Part I CNV Lab Paolo Besana 22-26 January 2007 This quick overview of Python is a reduced and altered version of the online tutorial written by Guido Van Rossum (the creator of

More information

L A TEX examples. a b c a b c b b a c b c c b a. This table was typeset with the following commands.

L A TEX examples. a b c a b c b b a c b c c b a. This table was typeset with the following commands. L A TEX examples This document is designed to help you see how to produce some mathematical typesetting. The best way to learn how to use L A TEX is to experiment with particular commands. After you have

More information

1 Lexical Considerations

1 Lexical Considerations Massachusetts Institute of Technology Department of Electrical Engineering and Computer Science 6.035, Spring 2013 Handout Decaf Language Thursday, Feb 7 The project for the course is to write a compiler

More information

Makefiles Makefiles should begin with a comment section of the following form and with the following information filled in:

Makefiles Makefiles should begin with a comment section of the following form and with the following information filled in: CS 215 Fundamentals of Programming II C++ Programming Style Guideline Most of a programmer's efforts are aimed at the development of correct and efficient programs. But the readability of programs is also

More information

Programming Basics and Practice GEDB029 Decision Making, Branching and Looping. Prof. Dr. Mannan Saeed Muhammad bit.ly/gedb029

Programming Basics and Practice GEDB029 Decision Making, Branching and Looping. Prof. Dr. Mannan Saeed Muhammad bit.ly/gedb029 Programming Basics and Practice GEDB029 Decision Making, Branching and Looping Prof. Dr. Mannan Saeed Muhammad bit.ly/gedb029 Decision Making and Branching C language possesses such decision-making capabilities

More information

Latex Tutorial 1 L A TEX. 1.1 Text

Latex Tutorial 1 L A TEX. 1.1 Text Latex Tutorial This tutorial was originally prepared by Joel Wein of MIT. You may find it helpful in preparing your notes. Anything I send you in the template file supercedes what is written here. Yishay

More information

Homework # (Latex Handout) by Laura Parkinson

Homework # (Latex Handout) by Laura Parkinson 1 Latex Homework # (Latex Handout) by Laura Parkinson Latex helps you make your homework pretty. It makes us happy when you use it. The best way to learn is by example, so here are some examples of pretty

More information

Chapter 8. Statement-Level Control Structures

Chapter 8. Statement-Level Control Structures Chapter 8 Statement-Level Control Structures Chapter 8 Topics Introduction Selection Statements Iterative Statements Unconditional Branching Guarded Commands Conclusions Copyright 2009 Addison-Wesley.

More information

Pace University. Fundamental Concepts of CS121 1

Pace University. Fundamental Concepts of CS121 1 Pace University Fundamental Concepts of CS121 1 Dr. Lixin Tao http://csis.pace.edu/~lixin Computer Science Department Pace University October 12, 2005 This document complements my tutorial Introduction

More information

MATLAB provides several built-in statements that allow for conditional behavior if/elseif/else switch menu

MATLAB provides several built-in statements that allow for conditional behavior if/elseif/else switch menu Chapter 3 What we have done so far: Scripts/Functions have executed all commands in order, not matter what What we often need: A piece of code that executes a series of commands, if and only if some condition

More information

LaTeX A Tutorial. Mohsen Alimomeni, 2010

LaTeX A Tutorial. Mohsen Alimomeni, 2010 LaTeX A Tutorial Mohsen Alimomeni, 2010 How to pronounce LaTeX? (Lah-tek, or Lay-tek) A typesetting program, not a word-processor Designed for producing beautiful books, thesis, papers, articles... (Springer

More information

COP4020 Programming Assignment 1 - Spring 2011

COP4020 Programming Assignment 1 - Spring 2011 COP4020 Programming Assignment 1 - Spring 2011 In this programming assignment we design and implement a small imperative programming language Micro-PL. To execute Mirco-PL code we translate the code to

More information

TUGboat, Volume 22 (2001), No. 1/2 87

TUGboat, Volume 22 (2001), No. 1/2 87 TUGboat, Volume 22 (2001), No. 1/2 87 Drawing Message Sequence Charts with L A TEX Sjouke Mauw and Victor Bos Abstract The MSC macro package facilitates L A TEX usersto easily include Message Sequence

More information

(Refer Slide Time 01:41 min)

(Refer Slide Time 01:41 min) Programming and Data Structure Dr. P.P.Chakraborty Department of Computer Science and Engineering Indian Institute of Technology, Kharagpur Lecture # 03 C Programming - II We shall continue our study of

More information

B.V. Patel Institute of Business Management, Computer & Information Technology, Uka Tarsadia University

B.V. Patel Institute of Business Management, Computer & Information Technology, Uka Tarsadia University Unit 1 Programming Language and Overview of C 1. State whether the following statements are true or false. a. Every line in a C program should end with a semicolon. b. In C language lowercase letters are

More information

Math 235: Introduction to LaTeX

Math 235: Introduction to LaTeX Math 235: Introduction to LaTeX The LaTeX word processing system was built to do mathematical typesetting. It is different than word processors; in LaTeX you type in text and typesetting commands, then

More information

Quick Reference Guide

Quick Reference Guide SOFTWARE AND HARDWARE SOLUTIONS FOR THE EMBEDDED WORLD mikroelektronika Development tools - Books - Compilers Quick Reference Quick Reference Guide with EXAMPLES for Pascal language This reference guide

More information

The Honours Dissertation Class for L A TEX2e. Cara MacNish

The Honours Dissertation Class for L A TEX2e. Cara MacNish The Honours Dissertation Class for L A TEX2e Cara MacNish This report is submitted as partial fulfilment of the requirements for the Honours Programme of the School of Computer Science and Software Engineering,

More information

Contents. Jairo Pava COMS W4115 June 28, 2013 LEARN: Language Reference Manual

Contents. Jairo Pava COMS W4115 June 28, 2013 LEARN: Language Reference Manual Jairo Pava COMS W4115 June 28, 2013 LEARN: Language Reference Manual Contents 1 Introduction...2 2 Lexical Conventions...2 3 Types...3 4 Syntax...3 5 Expressions...4 6 Declarations...8 7 Statements...9

More information

Lexical Considerations

Lexical Considerations Massachusetts Institute of Technology Department of Electrical Engineering and Computer Science 6.035, Fall 2005 Handout 6 Decaf Language Wednesday, September 7 The project for the course is to write a

More information

Getting Started with L A TEX

Getting Started with L A TEX Getting Started with L A TEX This document is designed to help you see how to produce some mathematical typesetting. The best way to learn how to use L A TEX is to experiment with particular commands.

More information

REPETITION CONTROL STRUCTURE LOGO

REPETITION CONTROL STRUCTURE LOGO CSC 128: FUNDAMENTALS OF COMPUTER PROBLEM SOLVING REPETITION CONTROL STRUCTURE 1 Contents 1 Introduction 2 for loop 3 while loop 4 do while loop 2 Introduction It is used when a statement or a block of

More information

CROSSREF Manual. Tools and Utilities Library

CROSSREF Manual. Tools and Utilities Library Tools and Utilities Library CROSSREF Manual Abstract This manual describes the CROSSREF cross-referencing utility, including how to use it with C, COBOL 74, COBOL85, EXTENDED BASIC, FORTRAN, Pascal, SCREEN

More information

(Refer Slide Time: 01:12)

(Refer Slide Time: 01:12) Internet Technology Prof. Indranil Sengupta Department of Computer Science and Engineering Indian Institute of Technology, Kharagpur Lecture No #22 PERL Part II We continue with our discussion on the Perl

More information

CSCE 314 TAMU Fall CSCE 314: Programming Languages Dr. Flemming Andersen. Haskell Functions

CSCE 314 TAMU Fall CSCE 314: Programming Languages Dr. Flemming Andersen. Haskell Functions 1 CSCE 314: Programming Languages Dr. Flemming Andersen Haskell Functions 2 Outline Defining Functions List Comprehensions Recursion 3 Conditional Expressions As in most programming languages, functions

More information

Visualization of Biomolecular Structures

Visualization of Biomolecular Structures T H E U N I V E R S I T Y of T E X A S H E A L T H S C I E N C E C E N T E R A T H O U S T O N S C H O O L of H E A L T H I N F O R M A T I O N S C I E N C E S Visualization of Biomolecular Structures

More information

L o o p s. for(initializing expression; control expression; step expression) { one or more statements }

L o o p s. for(initializing expression; control expression; step expression) { one or more statements } L o o p s Objective #1: Explain the importance of loops in programs. In order to write a non trivial computer program, you almost always need to use one or more loops. Loops allow your program to repeat

More information

CSc 372. Comparative Programming Languages. 2 : Functional Programming. Department of Computer Science University of Arizona

CSc 372. Comparative Programming Languages. 2 : Functional Programming. Department of Computer Science University of Arizona 1/37 CSc 372 Comparative Programming Languages 2 : Functional Programming Department of Computer Science University of Arizona collberg@gmail.com Copyright c 2013 Christian Collberg 2/37 Programming Paradigms

More information

Scientific Computing with MATLAB

Scientific Computing with MATLAB Scientific Computing with MATLAB Dra. K.-Y. Daisy Fan Department of Computer Science Cornell University Ithaca, NY, USA UNAM IIM 2012 2 Focus on computing using MATLAB Computer Science Computational Science

More information

Functions. Lecture 6 COP 3014 Spring February 11, 2018

Functions. Lecture 6 COP 3014 Spring February 11, 2018 Functions Lecture 6 COP 3014 Spring 2018 February 11, 2018 Functions A function is a reusable portion of a program, sometimes called a procedure or subroutine. Like a mini-program (or subprogram) in its

More information

Chapter 6 Control Flow. June 9, 2015

Chapter 6 Control Flow. June 9, 2015 Chapter 6 Control Flow June 9, 2015 Expression evaluation It s common in programming languages to use the idea of an expression, which might be a simple object function invocation over some number of arguments

More information

Control Structures. CIS 118 Intro to LINUX

Control Structures. CIS 118 Intro to LINUX Control Structures CIS 118 Intro to LINUX Basic Control Structures TEST The test utility, has many formats for evaluating expressions. For example, when given three arguments, will return the value true

More information

Chapter 2 Basic Elements of C++

Chapter 2 Basic Elements of C++ C++ Programming: From Problem Analysis to Program Design, Fifth Edition 2-1 Chapter 2 Basic Elements of C++ At a Glance Instructor s Manual Table of Contents Overview Objectives s Quick Quizzes Class Discussion

More information

Department of Computer Science COMP The Programming Competency Test

Department of Computer Science COMP The Programming Competency Test The Australian National University Faculty of Engineering & Information Technology Department of Computer Science COMP1120-2003-01 The Programming Competency Test 1 Introduction The purpose of COMP1120

More information

My Mathematical Thesis

My Mathematical Thesis My Mathematical Thesis A. Student September 1, 2018 Abstract An abstract is a paragraph or few that gives the reader an overview of the document. Abstracts are commonly found on research articles, but

More information

Crayon (.cry) Language Reference Manual. Naman Agrawal (na2603) Vaidehi Dalmia (vd2302) Ganesh Ravichandran (gr2483) David Smart (ds3361)

Crayon (.cry) Language Reference Manual. Naman Agrawal (na2603) Vaidehi Dalmia (vd2302) Ganesh Ravichandran (gr2483) David Smart (ds3361) Crayon (.cry) Language Reference Manual Naman Agrawal (na2603) Vaidehi Dalmia (vd2302) Ganesh Ravichandran (gr2483) David Smart (ds3361) 1 Lexical Elements 1.1 Identifiers Identifiers are strings used

More information

CS 189 L A TEX and Linux: Text in Boxes

CS 189 L A TEX and Linux: Text in Boxes CS 189 L A TEX and Linux: Text in Boxes (1) Robert S. Laramee Computer Science Department School of Physical Sciences Swansea University March 4, 2008 (1) Robert S. Laramee CS 189 LATEX and Linux: Text

More information

L A TEX Primer. Randall R. Holmes. August 17, 2018

L A TEX Primer. Randall R. Holmes. August 17, 2018 L A TEX Primer Randall R. Holmes August 17, 2018 Note: For this to make sense it needs to be read with the code and the compiled output side by side. And in order for the compiling to be successful, the

More information

Assoc. Prof. Dr. Marenglen Biba. (C) 2010 Pearson Education, Inc. All rights reserved.

Assoc. Prof. Dr. Marenglen Biba. (C) 2010 Pearson Education, Inc. All rights reserved. Assoc. Prof. Dr. Marenglen Biba (C) 2010 Pearson Education, Inc. All for repetition statement do while repetition statement switch multiple-selection statement break statement continue statement Logical

More information

Conditionals, Loops, and Style

Conditionals, Loops, and Style Conditionals, Loops, and Style yes x > y? no max = x; max = y; http://xkcd.com/292/ Fundamentals of Computer Science Keith Vertanen Copyright 2013 Control flow thus far public class ArgsExample public

More information

First Name: Last: ID# 1. Hexadecimal uses the symbols 1, 2, 3, 4, 5, 6, 7 8, 9, A, B, C, D, E, F,G.

First Name: Last: ID# 1. Hexadecimal uses the symbols 1, 2, 3, 4, 5, 6, 7 8, 9, A, B, C, D, E, F,G. IST 311 - Exam1 - Fall 2015 First Name: Last: ID# PART 1. Multiple-choice / True-False (30 poinst) 1. Hexadecimal uses the symbols 1, 2, 3, 4, 5, 6, 7 8, 9, A, B, C, D, E, F,G. 2. The accessibility modifier

More information

C++ for Python Programmers

C++ for Python Programmers C++ for Python Programmers Adapted from a document by Rich Enbody & Bill Punch of Michigan State University Purpose of this document This document is a brief introduction to C++ for Python programmers

More information

Building Applications

Building Applications V B. N E T P r o g r a m m i n g, T h e B a s i c C o n c e p t s a n d To o l s E n g. H a s a n A l h o u r i Building Applications analyzing designing coding testing deploying Eng. Hasan Alhouri 1 Programming

More information

2/3/2018 CS313D: ADVANCED PROGRAMMING LANGUAGE. Lecture 3: C# language basics II. Lecture Contents. C# basics. Methods Arrays. Dr. Amal Khalifa, Spr17

2/3/2018 CS313D: ADVANCED PROGRAMMING LANGUAGE. Lecture 3: C# language basics II. Lecture Contents. C# basics. Methods Arrays. Dr. Amal Khalifa, Spr17 CS313D: ADVANCED PROGRAMMING LANGUAGE Lecture 3: C# language basics II Lecture Contents 2 C# basics Methods Arrays 1 Methods : Method Declaration: Header 3 A method declaration begins with a method header

More information

Styles and Conditional Features

Styles and Conditional Features Styles and Conditional Features Intellicus Enterprise Reporting and BI Platform Intellicus Technologies info@intellicus.com www.intellicus.com Copyright 2010 Intellicus Technologies This document and its

More information

6.001 Notes: Section 4.1

6.001 Notes: Section 4.1 6.001 Notes: Section 4.1 Slide 4.1.1 In this lecture, we are going to take a careful look at the kinds of procedures we can build. We will first go back to look very carefully at the substitution model,

More information

9.2 Linux Essentials Exam Objectives

9.2 Linux Essentials Exam Objectives 9.2 Linux Essentials Exam Objectives This chapter will cover the topics for the following Linux Essentials exam objectives: Topic 3: The Power of the Command Line (weight: 10) 3.3: Turning Commands into

More information

Algorithms. M. R. C. van Dongen. ucc. LaTEX and Friends Algorithms. Marc van Dongen. Algorithms and Listings

Algorithms. M. R. C. van Dongen.  ucc. LaTEX and Friends Algorithms. Marc van Dongen. Algorithms and Listings and Listings http://csweb.ucc.ie/~dongen/laf/laf.html M. R. C. van Dongen ucc Loading the Package and Listings Use algorithm2e [Fiorio 2004] for pseudo code algorithms. Choosing right option saves time/space.

More information

The design recipe. Readings: HtDP, sections 1-5. (ordering of topics is different in lectures, different examples will be used)

The design recipe. Readings: HtDP, sections 1-5. (ordering of topics is different in lectures, different examples will be used) The design recipe Readings: HtDP, sections 1-5 (ordering of topics is different in lectures, different examples will be used) Survival and Style Guides CS 135 Winter 2018 02: The design recipe 1 Programs

More information

CS1100 Introduction to Programming

CS1100 Introduction to Programming Decisions with Variables CS1100 Introduction to Programming Selection Statements Madhu Mutyam Department of Computer Science and Engineering Indian Institute of Technology Madras Course Material SD, SB,

More information

Chapter 8. Statement-Level Control Structures ISBN

Chapter 8. Statement-Level Control Structures ISBN Chapter 8 Statement-Level Control Structures ISBN 0-321-49362-1 Chapter 8 Topics Introduction Selection Statements Iterative Statements Unconditional Branching Guarded Commands Conclusions Copyright 2012

More information

Object oriented programming. Instructor: Masoud Asghari Web page: Ch: 3

Object oriented programming. Instructor: Masoud Asghari Web page:   Ch: 3 Object oriented programming Instructor: Masoud Asghari Web page: http://www.masses.ir/lectures/oops2017sut Ch: 3 1 In this slide We follow: https://docs.oracle.com/javase/tutorial/index.html Trail: Learning

More information

OBJECT ORIENTED SIMULATION LANGUAGE. OOSimL Reference Manual - Part 1

OBJECT ORIENTED SIMULATION LANGUAGE. OOSimL Reference Manual - Part 1 OBJECT ORIENTED SIMULATION LANGUAGE OOSimL Reference Manual - Part 1 Technical Report TR-CSIS-OOPsimL-1 José M. Garrido Department of Computer Science Updated November 2014 College of Computing and Software

More information

\n is used in a string to indicate the newline character. An expression produces data. The simplest expression

\n is used in a string to indicate the newline character. An expression produces data. The simplest expression Chapter 1 Summary Comments are indicated by a hash sign # (also known as the pound or number sign). Text to the right of the hash sign is ignored. (But, hash loses its special meaning if it is part of

More information

CMAT Language - Language Reference Manual COMS 4115

CMAT Language - Language Reference Manual COMS 4115 CMAT Language - Language Reference Manual COMS 4115 Language Guru: Michael Berkowitz (meb2235) Project Manager: Frank Cabada (fc2452) System Architect: Marissa Ojeda (mgo2111) Tester: Daniel Rojas (dhr2119)

More information

SAS Programming Basics

SAS Programming Basics SAS Programming Basics SAS Programs SAS Programs consist of three major components: Global statements Procedures Data steps SAS Programs Global Statements Procedures Data Step Notes Data steps and procedures

More information

C++ Basics. Data Processing Course, I. Hrivnacova, IPN Orsay

C++ Basics. Data Processing Course, I. Hrivnacova, IPN Orsay C++ Basics Data Processing Course, I. Hrivnacova, IPN Orsay The First Program Comments Function main() Input and Output Namespaces Variables Fundamental Types Operators Control constructs 1 C++ Programming

More information

UEE1302 (1102) F10: Introduction to Computers and Programming

UEE1302 (1102) F10: Introduction to Computers and Programming Computational Intelligence on Automation Lab @ NCTU Learning Objectives UEE1302 (1102) F10: Introduction to Computers and Programming Programming Lecture 00 Programming by Example Introduction to C++ Origins,

More information

2.1. Chapter 2: Parts of a C++ Program. Parts of a C++ Program. Introduction to C++ Parts of a C++ Program

2.1. Chapter 2: Parts of a C++ Program. Parts of a C++ Program. Introduction to C++ Parts of a C++ Program Chapter 2: Introduction to C++ 2.1 Parts of a C++ Program Copyright 2009 Pearson Education, Inc. Publishing as Pearson Addison-Wesley 2-1 Parts of a C++ Program Parts of a C++ Program // sample C++ program

More information

Indian Institute of Technology Kharagpur. PERL Part II. Prof. Indranil Sen Gupta Dept. of Computer Science & Engg. I.I.T.

Indian Institute of Technology Kharagpur. PERL Part II. Prof. Indranil Sen Gupta Dept. of Computer Science & Engg. I.I.T. Indian Institute of Technology Kharagpur PERL Part II Prof. Indranil Sen Gupta Dept. of Computer Science & Engg. I.I.T. Kharagpur, INDIA Lecture 22: PERL Part II On completion, the student will be able

More information

Example. CS 201 Selection Structures (2) and Repetition. Nested if Statements with More Than One Variable

Example. CS 201 Selection Structures (2) and Repetition. Nested if Statements with More Than One Variable CS 201 Selection Structures (2) and Repetition Debzani Deb Multiple-Alternative Decision Form of Nested if Nested if statements can become quite complex. If there are more than three alternatives and indentation

More information

Loops! Loops! Loops! Lecture 5 COP 3014 Fall September 25, 2017

Loops! Loops! Loops! Lecture 5 COP 3014 Fall September 25, 2017 Loops! Loops! Loops! Lecture 5 COP 3014 Fall 2017 September 25, 2017 Repetition Statements Repetition statements are called loops, and are used to repeat the same code mulitple times in succession. The

More information

Template and Tutorial for Math Modelers

Template and Tutorial for Math Modelers LaTeX Template and Tutorial for Math Modelers November 19, 2011 Your abstract or summary can go here. Abstract 1 Team # 123 Page 2 of 7 Contents 1 Introduction 3 2 Now You Try It 6 2.1 Assumptions......................................

More information

epub WU Institutional Repository

epub WU Institutional Repository epub WU Institutional Repository Gunther Maier LaTeX - Know what you are missing Article (Published) (Refereed) Original Citation: Maier, Gunther (2016) LaTeX - Know what you are missing. REGION, 3 (2).

More information

Logical Operators and if/else statement. If Statement. If/Else (4.3)

Logical Operators and if/else statement. If Statement. If/Else (4.3) Logical Operators and if/ statement 1 If Statement We may want to execute some code if an expression is true, and execute some other code when the expression is false. This can be done with two if statements

More information

L A TEX for Psychological Researchers

L A TEX for Psychological Researchers L A TEX for Psychological Researchers Lecture 2: Basics of the L A TEX language Sacha Epskamp University of Amsterdam Department of Psychological Methods 27-01-2015 The L A TEX process.tex pdfl A TEX.pdf

More information

Fundamentals of Programming Session 4

Fundamentals of Programming Session 4 Fundamentals of Programming Session 4 Instructor: Reza Entezari-Maleki Email: entezari@ce.sharif.edu 1 Fall 2011 These slides are created using Deitel s slides, ( 1992-2010 by Pearson Education, Inc).

More information

Intro to LATEX I. Aaron Erlich POLS/CSSS 510, Why LATEX? Programming Document Structure Floats Tables Lists Math

Intro to LATEX I. Aaron Erlich POLS/CSSS 510, Why LATEX? Programming Document Structure Floats Tables Lists Math Intro to LATEX I 1 1 POLS/CSSS 510, 2012 Intro to LATEX I 1 / 32 Outline 1 Why L A TEX? 2 Programming 3 Document Structure 4 Floats 5 Tables 6 Lists 7 Math Intro to LATEX I 2 / 32 The Complaint This sucks

More information

Fachgebiet Softwaretechnik, Heinz Nixdorf Institut, Universität Paderborn. 4. Testing

Fachgebiet Softwaretechnik, Heinz Nixdorf Institut, Universität Paderborn. 4. Testing 4. vs. Model Checking (usually) means checking the correctness of source code Model Checking means verifying the properties of a model given in some formal (not program code) notation Attention: things

More information

Algorithms. Rogério Brito 16 March 2005

Algorithms. Rogério Brito 16 March 2005 Algorithms Rogério Brito rbrito@ime.usp.br 16 March 2005 Contents 1 Introduction 2 2 The algorithmic Environment 2 2.1 The Simple Statement........................ 2 2.2 The if-then-else Construct......................

More information

JavaScript Basics. The Big Picture

JavaScript Basics. The Big Picture JavaScript Basics At this point, you should have reached a certain comfort level with typing and running JavaScript code assuming, of course, that someone has already written it for you This handout aims

More information

Chapter 1 Summary. Chapter 2 Summary. end of a string, in which case the string can span multiple lines.

Chapter 1 Summary. Chapter 2 Summary. end of a string, in which case the string can span multiple lines. Chapter 1 Summary Comments are indicated by a hash sign # (also known as the pound or number sign). Text to the right of the hash sign is ignored. (But, hash loses its special meaning if it is part of

More information

Version v2.01, 2000/06/29

Version v2.01, 2000/06/29 The amstext package Frank Mittelbach Rainer Schöpf Version v2.01, 2000/06/29 1 Introduction This file is maintained by the L A TEX Project team. Bug reports can be opened (category amsmath) at http://latex-project.org/bugs.html.

More information

Conditional Control Structures. Dr.T.Logeswari

Conditional Control Structures. Dr.T.Logeswari Conditional Control Structures Dr.T.Logeswari TEST COMMAND test expression Or [ expression ] Syntax Ex: a=5; b=10 test $a eq $b ; echo $? [ $a eq $b] ; echo $? 2 Unix Shell Programming - Forouzan 2 TEST

More information

Using ShareLaTeX to make Trees

Using ShareLaTeX to make Trees Using ShareLaeX to make rees Alan Munn September 2016 1 Introduction he ShareLaeX site http://sharelatex.com/ is a cloud-based LaeX system. LaeX is a complete typesetting system which converts a plain

More information

C++ Programming: From Problem Analysis to Program Design, Third Edition

C++ Programming: From Problem Analysis to Program Design, Third Edition C++ Programming: From Problem Analysis to Program Design, Third Edition Chapter 2: Basic Elements of C++ Objectives (continued) Become familiar with the use of increment and decrement operators Examine

More information

9. Elementary Algebraic and Transcendental Scalar Functions

9. Elementary Algebraic and Transcendental Scalar Functions Scalar Functions Summary. Introduction 2. Constants 2a. Numeric Constants 2b. Character Constants 2c. Symbol Constants 2d. Nested Constants 3. Scalar Functions 4. Arithmetic Scalar Functions 5. Operators

More information

Key Differences Between Python and Java

Key Differences Between Python and Java Python Python supports many (but not all) aspects of object-oriented programming; but it is possible to write a Python program without making any use of OO concepts. Python is designed to be used interpretively.

More information

ü 1.1 Getting Started

ü 1.1 Getting Started Chapter 1 Introduction Welcome to Mathematica! This tutorial manual is intended as a supplement to Rogawski's Calculus textbook and aimed at students looking to quickly learn Mathematica through examples.

More information

LECTURE 5 Control Structures Part 2

LECTURE 5 Control Structures Part 2 LECTURE 5 Control Structures Part 2 REPETITION STATEMENTS Repetition statements are called loops, and are used to repeat the same code multiple times in succession. The number of repetitions is based on

More information

UNIT-IV: MACRO PROCESSOR

UNIT-IV: MACRO PROCESSOR UNIT-IV: MACRO PROCESSOR A Macro represents a commonly used group of statements in the source programming language. A macro instruction (macro) is a notational convenience for the programmer o It allows

More information

Lexical Considerations

Lexical Considerations Massachusetts Institute of Technology Department of Electrical Engineering and Computer Science 6.035, Spring 2010 Handout Decaf Language Tuesday, Feb 2 The project for the course is to write a compiler

More information

Ch. 7: Control Structures

Ch. 7: Control Structures Ch. 7: Control Structures I. Introduction A. Flow of control can be at multiple levels: within expressions, among statements (discussed here), and among units. B. Computation in imperative languages uses

More information

Kingdom of Saudi Arabia Princes Nora bint Abdul Rahman University College of Computer Since and Information System CS240 BRANCHING STATEMENTS

Kingdom of Saudi Arabia Princes Nora bint Abdul Rahman University College of Computer Since and Information System CS240 BRANCHING STATEMENTS Kingdom of Saudi Arabia Princes Nora bint Abdul Rahman University College of Computer Since and Information System CS240 BRANCHING STATEMENTS Objectives By the end of this section you should be able to:

More information