Monday, September 8, 2014 CSCI 351 – Mobile Applications Development.

Slides:



Advertisements
Similar presentations
JavaScript I. JavaScript is an object oriented programming language used to add interactivity to web pages. Different from Java, even though bears some.
Advertisements

CSci 1130 Intro to Programming in Java
Operators and Expressions Operators are symbols that produce a result based on some rules. Examples: +, -, =, > and
Chapter 41 Variables and JSP Control Structures JavaServer Pages By Xue Bai.
Lecture 1 Introduction to Java Erick Pranata © Sekolah Tinggi Teknik Surabaya 1.
Primitive Data Types There are a number of common objects we encounter and are treated specially by almost any programming language These are called basic.
Javascript Essentials How do I write it??  Start Homesite  Between the start and end BODY tags type: 
Bellevue University CIS 205: Introduction to Programming Using C++ Lecture 3: Primitive Data Types.
Data types and variables
C programming an Introduction. Types There are only a few basic data types in C. char a character int an integer, in the range -32,767 to 32,767 long.
Primitive Types Java supports two kinds of types of values – objects, and – values of primitive data types variables store – either references to objects.
Chapter 2 Data Types, Declarations, and Displays
JavaScript, Third Edition
1 Chapter 2: Elementary Programming Shahriar Hossain.
CSci 142 Data and Expressions. 2  Topics  Strings  Primitive data types  Using variables and constants  Expressions and operator precedence  Data.
String Escape Sequences
Objectives You should be able to describe: Data Types
1 Variables, Constants, and Data Types Primitive Data Types Variables, Initialization, and Assignment Constants Characters Strings Reading for this class:
CSCI 1100/1202 January 16, Why do we need variables? To store intermediate results in a long computation. To store a value that is used more than.
Java Primitives The Smallest Building Blocks of the Language (corresponds with Chapter 2)
CPTR 124 Review for Test 1. Development Tools Editor Similar to a word processor Allows programmer to compose/save/edit source code Compiler/interpreter.
2440: 211 Interactive Web Programming Expressions & Operators.
C-Language Keywords(C99)
Chapter 3: Data Types and Operators JavaScript - Introductory.
1 Do you have a CS account? Primitive types –“ building blocks ” for more complicated types Java is strongly typed –All variables in a Java program must.
Simple Data Types and Statements. Namespaces namespace MyNamespace { // …. { MyNamespace::func1() using namespace OtherNamespace; Comments: // /* xxxx.
JAVA Tokens. Introduction A token is an individual element in a program. More than one token can appear in a single line separated by white spaces.
Chapter 2 Elementary Programming
Knowledge Base C++ #include using std namespace; int main(){} return 0 ; cout
Introduction to C Programming Chapter 2 : Data Input, Processing and Output.
ITM © Port, KazmanVariables - 1 ITM 352 Expressions, Precedence, Working with Strings.
CHAPTER 4 GC 101 Data types. DATA TYPES  For all data, assign a name (identifier) and a data type  Data type tells compiler:  How much memory to allocate.
At the end of the module the students should be able to:  Familiarize themselves with the different uses of constants, operators, and expressions in.
CS346 Javascript -3 Module 3 JavaScript Variables.
Data Types Declarations Expressions Data storage C++ Basics.
CHAPTER 2 C++ SYNTAX & SEMANTICS #include using namespace std; int main() { cout
A Simple Java Program //This program prints Welcome to Java! public class Welcome { public static void main(String[] args) { public static void main(String[]
Programming in Java (COP 2250) Lecture 4 Chengyong Yang Fall, 2005.
Operators and Expressions. 2 String Concatenation  The plus operator (+) is also used for arithmetic addition  The function that the + operator performs.
Basic Variables & Operators Web Programming1. Review: Perl Basics Syntax ► Comments: start with # (ignored by Perl) ► Statements: ends with ; (performed.
Ajmer Singh PGT(IP) Programming Fundamentals. Ajmer Singh PGT(IP) Java Character Set Character set is a set of valid characters that a language can recognize.
CSM-Java Programming-I Spring,2005 Fundamental Data Types Lesson - 2.
Chapter 14 JavaScript: Part II The Web Warrior Guide to Web Design Technologies.
© 2007 Pearson Addison-Wesley. All rights reserved2-1 Character Strings A string of characters can be represented as a string literal by putting double.
Basic Scripting & Variables Yasar Hussain Malik - NISTE.
Characters and Strings
What are Operators? Some useful operators to get you started.
CSCI 1100/1202 January 14, Abstraction An abstraction hides (or ignores) the right details at the right time An object is abstract in that we don't.
JAVA Programming (Session 2) “When you are willing to make sacrifices for a great cause, you will never be alone.” Instructor: รัฐภูมิ เถื่อนถนอม
Chapter 2: Data and Expressions. Variable Declaration In Java when you declare a variable, you must also declare the type of information it will hold.
Wednesday, September 3, 2014 CSCI 351 – Mobile Applications Development.
1.  Algorithm: 1. Read in the radius 2. Compute the area using the following formula: area = radius x radius x PI 3. Display the area 2.
© 2004 Pearson Addison-Wesley. All rights reserved August 27, 2007 Primitive Data Types ComS 207: Programming I (in Java) Iowa State University, FALL 2007.
Chapter 2 Variables.
Wel come.
Primitive Data Types August 28, 2006 ComS 207: Programming I (in Java)
Multiple variables can be created in one declaration
Scope, Objects, Strings, Numbers
Chapter 2 Elementary Programming
Arithmetic Operator Operation Example + addition x + y
Escape Sequences What if we wanted to print the quote character?
With Assignment Operator
Basics of ‘C’.
Java Programming Language
Chapter 2 Variables.
Lexical Elements & Operators
Chapter 2 Primitive Data Types and Operations
HNDIT11034 More Operators.
Programming Fundamental-1
Presentation transcript:

Monday, September 8, 2014 CSCI 351 – Mobile Applications Development

Swift – assignment Most operators in Swift behave similar to those of C or C++ let x = 7 var y = 10 y = x // assign statement does not return a value if y=x { // this produces an error in Swift println("Hi") } (m,n,p) = (2,3,9) // can use assignment with tuples

Swift – operators Arithmetic operators in Swift let a = let b = let c = 3 * -2 let d = 9 / 2 // integer division let e = 9 / 2.0 // floating point division let f = 13 % 5 let g = 11.5 % 4.5 // remainder works w floating point let h = "dog" + "house" // concatenation with strings let i = "O" + "K" // or characters let j = - a // unary minus

Swift – increment and decrement What will this code produce? var j = 5 var k = j++ var l = ++k j k l var m = 5 m *= 2

Swift – comparison operators The six comparison operators: ==, !=,, >= Ternary conditional operator: let score = 73 var grade = (score >= 70) ? "pass" : "fail" Compound operators: &&, ||, !

Swift – ranges A range from a to b is given by (a...b) for num in { println("\(num) times 10 is \(num*10)") } Using a range to cycle through an array: let names = ["Anna", "Alex", "Brian", "Jack"] let numItems = names.count for m in 0...numItems-1 { println("Name \(m + 1) is called \(names[m])") }

Swift – characters and strings Unicode character set: A string literal: let today = "Monday" M String literals can include the following special characters: The escaped special characters \0 (null character), \\ (backslash), \t (horizontal tab), \n (line feed), \r (carriage return), \" (double quote) and \' (single quote) Single-byte Unicode scalars, written as \xnn, where nn is two hexadecimal digits Two-byte Unicode scalars, written as \unnnn, where nnnn is four hexadecimal digits Four-byte Unicode scalars, written as \Unnnnnnnn, where nnnnnnnn is eight hexadecimal digits