3. Java - Language Constructs I
|
|
- Tracey Grant
- 5 years ago
- Views:
Transcription
1 Names and Identifiers A program (that is, a class) needs a name public class SudokuSolver { Java - Language Constructs I Names and Identifiers, Variables, Assignments, Constants, Datatypes, Operations, Evaluation of Expressions, Type Conversions Convention for class names: use CamelCase Words are combined into one word, each starting with a capital letter Allowed names for entities in a program: Names begin with a letter or _ or $ Then, sequence of letters, numbers or _ or $ Names - what is allowed Keywords The following words are already used by the language and cannot be used as names: _myname AN$WE4_1S_42 $bling$ TheCure me@home strictfp 49ers?! side-swipe Ph.D s abstract continue for new switch assert default goto package synchronized boolean do if private this break double implements protected throw byte else import public throws case enum instanceof return transient catch extends int short try char final interface static void class finally long strictfp volatile const float native super while 64 65
2 Variables and Constants Constants Variables are buckets for a value Have a data type and a name The data type determines what kind of values are allowed in the variable int x 23 int y 42 float f 0.0f char c a Declaration in Java: int x = 23, y = 42; float f; char c = a ; Keyword final The value of the variable can be set exactly once final int maxsize = 100; Hint: Always use final, unless the value actually needs to change over time. Initialization Standard Types Types and Memory Usage Data Type Definition Value Range Initial Value byte 8-bit integer 128,..., short 16-bit integer ,..., int 32-bit integer 2 31,..., long 64-bit integer 2 63,..., L float 32-bit floating point ±1.4E 45,..., ±3.4E f double 64-bit floating point ±4.9E 324,..., ±1.7E d Reminder: Memory cells contain 1 Byte = 8 bit boolean byte short, char boolean logical value true, false false char unicode-16 character \u0000,..., a, b,..., \uffff \u0000 String string null int, float long, double 68 69
3 Literals: Integer Numbers Type int (or short, byte) 12 : value 12-3 : value 3 Type long 25_872_224L : value Literals: Floating Point Numbers are different from integers by providing decimal comma 1.0 : type double, value f : type float, value 1.27 and / or exponent. 1e3 : type double, value 1000 integer part 1.23e-7f fractional part exponent Hint: Underscores between digits are allowed! e-7 : type double, value e-7f : type float, value Literals: Characters and Strings Character: In ASCII Table Individual characters: a : Type char, value 97 Strings: "Hello There!" : Type String "a" : Type String Mind: Characters and Strings are two different things! 72 73
4 Value Assignment Copies a value into variable x In pseudo code: x value In Java: x = value value = is the assignment operator and not a comparison! x (copy) value Therefore, int y = 42 is both a declaration + an assignment. Value Assignment s int a = 3; double b; b = 3.141; int c = a = 0; String name = "Inf"; A nested assignment: The expression a = 0 stores the value 0 into variable a. and then returns the value Arithmetic Binary Operators Arithmetic Binary Operators Infix notation: x op y with the following operators op: + / % modulo Precedence: Multiplication, division, and modulo first, then addition and subtraction Associativity: Evaluation from left to right Division x / y: Integer division if x and y are integer. Division x / y: Floating-point division if x or y is a floating-poing number! s Integer division and modulo 5 / 3 evaluates to 1 5 / 3 evaluates to 1 5 % 3 evaluates to 2 5 % 3 evaluates to
5 Arithmetic Assignment Arithmetic Unary Operators x = x + y x += y Analogous for,, /, % s: x = 3; // x = x 3 name += "x" // name = name + "x" num = 2; // num = num 2 Prefix notation: + x or x Precedence: Unary operators bind stronger than binary operators s Assuming x is 3 2 x evaluates to 6 x +1 evaluates to Increment/Decrement Operators Increment operators ++x and x++ have the same effect: x x + 1.But different return values: Prefix operator ++x returns the new value: a = ++x; x = x + 1; a = x; Postfix operator x++ returns the old value: a = x++; temp = x; x = x + 1; a= temp; Precedence: Increment and decrement operators bind stronger than unary operators Analogous for x and x. Increment/Decrement Operators s Assuming x is initially set to 2 y = ++x 3 evaluates to: x is 3 and y is 9 y = x++ 3 evaluates to: x is 3 and y is
6 Expressions Expressions represent computations are either primary or composed from other expressions, using operators are statically typed s primary: 4.1d or x or "Hi" composed: x + y or f 2.1f The type of f is float Analogy: Construction kit Celsius to Fahrenheit Celsius to Fahrenheit - Analysis public class Main { } public static void main(string[] args) { Out.print("Celsius: "); int celsius = In.readInt(); float fahrenheit = 9 * celsius / ; Out.println("Fahrenheit: " + fahrenheit); } : 15 Celsius are 59 Fahrenheit 9 * celsius / Arithmetic expression, contains three literals, one variable, three operator symbols Where are the brackets in this expression? 84 85
7 Rule 1: Precedence Rule 2: Associativity Multiplicative operators (*, /, %) have a higher precedence ("bind stronger") than additive operators (+, -). Arithmetic operators (*, /, %, +, -) are left-associative: in case of the same precedence, the evaluation happens from left to right. 9 * celsius / means (9 * celsius / 5) * celsius / means ((9 * celsius) / 5) Rule 3: Arity Bracketing Unary operators +, - before binary operators +, -. 9 * celsius / means 9 * celsius / (+5) + 32 Any expression can be bracketed unambiguously using the associativities precedences arities (number of operands) of the involved operators
8 Expression Trees Bracketing leads to an expression tree (((9 * celsius) / 5) + 32) 9 celsius 5 32 * / + Evaluation Order From leafs to the root in the expression tree 9 * celsius / celsius 5 32 * / Expression Trees Notation Usual notation: root on top 9 * celsius / Type System Java festures a static type system: All types must be declared If possible, the compiler checks the typing otherwise it s checked at run-time / 32 Advantages of a static type system * 9 celsius 5 Fail-fast Bugs in the program are often found already by the compiler Understandable code 92 93
9 Type errors int pi_ish; float pi = 3.14f; pi_ish = pi; Explicit Type Conversion int pi_ish; float pi = 3.14f; pi_ish = (int) pi; Compiler error:./root/main.java:12: error: incompatible types: possible lossy conversion from float to int pi_ish = pi; ^ Explicit type conversion using casts (type) Statically type-correct, compiler is happy Run-time behavior: depends on the situation Here: loss of precision: Can crash a program at run-time 95 Type Conversion - Visually for Integer Numbers Mixed Expressions, Conversion explicit cast byte short int long implicit conversion Floating point numbers are more general than integers. In mixed expressions integers are converted to floating point numbers. 9 * celsius / Potential loss of information when casting explicitly, because less memory available to represent the number 96 97
10 Type Conversions for Binary Operations Numeric operands in a binary operation are being converted according to the following rules: If both operands have the same type, no conversion will happen If one operand is double, the other operand is converted to double as well If one operand is float, the other operand is converted to float as well If one operand is long, the other operand is converted to long as well Otherwise: Both operands are being converted to int 4. Efficiency of algorithms Efficiency of Algorithms, Random Access Machine Model, Function Growth, Asymptotics [Cormen et al, Kap. 2.2,3, Ottman/Widmayer, Kap. 1.1] Efficiency of Algorithms Technology Model Random Access Machine (RAM) Goals Quantify the runtime behavior of an algorithm independent of the machine. Compare efficiency of algorithms. Understand dependece on the input size. Execution model: instructions are executed one after the other (on one processor core). Memory model: constant access time. Fundamental operations: computations (+,,,...) comparisons, assignment / copy, flow control (jumps) Unit cost model: fundamental operations provide a cost of 1. Data types: fundamental types like size-limited integer or floating point number
11 Size of the Input Data Asymptotic behavior An exact running time can normally not be predicted even for small input data. Typical: number of input objects (of fundamental type). Sometimes: number bits for a reasonable / cost-effective representation of the data. We consider the asymptotic behavior of the algorithm. And ignore all constant factors. An operation with cost 20 is no worse than one with cost 1 Linear growth with gradient 5 is as good as linear growth with gradient Superficially 4.2 Function growth O, Θ, Ω [Cormen et al, Kap. 3; Ottman/Widmayer, Kap. 1.1] Use the asymptotic notation to specify the execution time of algorithms. We write Θ(n 2 ) and mean that the algorithm behaves for large n like n 2 : when the problem size is doubled, the execution time multiplies by four
12 More precise: asymptotic upper bound Graphic provided: a function g : N R. Definition: O(g) = {f : N R c > 0, n 0 N : 0 f(n) c g(n) n n 0 } g(n) = n 2 f O(g) Notation: O(g(n)) := O(g( )) = O(g). h O(g) 106 n s Property O(g) = {f : N R c > 0, n 0 N : 0 f(n) c g(n) n n 0 } f(n) f O(?) 3n + 4 O(n) c = 4, n 0 = 4 2n O(n) c = 2, n 0 = 0 n n O(n 2 ) c = 2, n 0 = 100 n + n O(n) c = 2, n 0 = 1 f 1 O(g), f 2 O(g) f 1 + f 2 O(g)
13 Converse: asymptotic lower bound Given: a function g : N R. Definition: Ω(g) = {f : N R c > 0, n 0 N : 0 c g(n) f(n) n n 0 } h Ω(g) f Ω(g) g(n) = n n Asymptotic tight bound Given: function g : N R. Definition: g(n) = n 2 f Θ(n 2 ) Θ(g) := Ω(g) O(g). Simple, closed form: exercise. h(n) = 0.5 n
14 Notions of Growth Small n O(1) bounded array access O(log log n) double logarithmic interpolated binary sorted sort O(log n) logarithmic binary sorted search O( n) like the square root naive prime number test O(n) linear unsorted naive search O(n log n) superlinear / loglinear good sorting algorithms O(n 2 ) quadratic simple sort algorithms O(n c ) polynomial matrix multiply O(2 n ) exponential Travelling Salesman Dynamic Programming O(n!) factorial Travelling Salesman naively n 4 2 n n 2 n ln n Larger n Large n n n n n 2 log n 0.2 n 4 n log n
15 Logarithms 1, n 2 n 3/2 n log n n log n Time Consumption Assumption 1 Operation = 1µs. problem size log 2 n 1µs 7µs 13µs 20µs 30µs n 1µs 100µs 1/100s 1s 17 minutes n log 2 n 1µs 700µs 13/100µs 20s 8.5 hours n 2 1µs 1/100s 1.7 minutes 11.5 days 317 centuries 2 n 1µs centuries A good strategy?... Then I simply buy a new machine If today I can solve a problem of size n, then with a 10 or 100 times faster machine I can solve... Komplexität (speed 10) (speed 100) log 2 n n n 10 n n 100 n n 10 n n 100 n n 2 n 3.16 n n 10 n 2 n n n n n s n O(n 2 ) correct, but too imprecise: n O(n) and even n Θ(n). 3n 2 O(2n 2 ) correct but uncommon: Omit constants: 3n 2 O(n 2 ). 2n 2 O(n) is wrong: 2n2 cn = 2 c n n! O(n) O(n 2 ) is correct Θ(n) Θ(n 2 ) is wrong n Ω(n 2 ) Θ(n 2 )
16 Useful Tool Theorem Let f, g : N R + be two functions, then it holds that f(n) 1 lim n g(n) f(n) 2 lim n g(n) 3 f(n) g(n) = 0 f O(g), O(f) O(g). = C > 0 (C constant) f Θ(g). n g O(f), O(g) O(f). About the Notation Common notation f = O(g) should be read as f O(g). Clearly it holds that f 1 = O(g), f 2 = O(g) f 1 = f 2! Beispiel n = O(n 2 ), n 2 = O(n 2 ) but naturally n n Algorithms, Programs and Execution Time Program: concrete implementation of an algorithm. Execution time of the program: measurable value on a concrete machine. Can be bounded from above and below. Beispiel 3GHz computer. Maximal number of operations per cycle (e.g. 8). lower bound. A single operations does never take longer than a day upper bound. From an asymptotic point of view the bounds coincide. 124 Complexity Complexity of a problem P : minimal (asymptotic) costs over all algorithms A that solve P. Complexity of the single-digit multiplication of two numbers with n digits is Ω(n) and O(n log 3 2 ) (Karatsuba Ofman). : Problem Complexity O(n) O(n) O(n 2 ) Algorithm Costs 2 3n 4 O(n) Θ(n 2 ) Program Execution time Θ(n) O(n) Θ(n 2 ) 2 Number funamental operations 125
3. Java - Language Constructs I
Educational Objectives 3. Java - Language Constructs I Names and Identifiers, Variables, Assignments, Constants, Datatypes, Operations, Evaluation of Expressions, Type Conversions You know the basic blocks
More informationCS5000: Foundations of Programming. Mingon Kang, PhD Computer Science, Kennesaw State University
CS5000: Foundations of Programming Mingon Kang, PhD Computer Science, Kennesaw State University Overview of Source Code Components Comments Library declaration Classes Functions Variables Comments Can
More informationCSC 1214: Object-Oriented Programming
CSC 1214: Object-Oriented Programming J. Kizito Makerere University e-mail: jkizito@cis.mak.ac.ug www: http://serval.ug/~jona materials: http://serval.ug/~jona/materials/csc1214 e-learning environment:
More informationComputer Components. Software{ User Programs. Operating System. Hardware
Computer Components Software{ User Programs Operating System Hardware What are Programs? Programs provide instructions for computers Similar to giving directions to a person who is trying to get from point
More informationExpressions and Data Types CSC 121 Spring 2015 Howard Rosenthal
Expressions and Data Types CSC 121 Spring 2015 Howard Rosenthal Lesson Goals Understand the basic constructs of a Java Program Understand how to use basic identifiers Understand simple Java data types
More informationCOMP 202 Java in one week
COMP 202 Java in one week... Continued CONTENTS: Return to material from previous lecture At-home programming exercises Please Do Ask Questions It's perfectly normal not to understand everything Most of
More informationAccelerating Information Technology Innovation
Accelerating Information Technology Innovation http://aiti.mit.edu Cali, Colombia Summer 2012 Lesson 02 Variables and Operators Agenda Variables Types Naming Assignment Data Types Type casting Operators
More informationAP COMPUTER SCIENCE JAVA CONCEPTS IV: RESERVED WORDS
AP COMPUTER SCIENCE JAVA CONCEPTS IV: RESERVED WORDS PAUL L. BAILEY Abstract. This documents amalgamates various descriptions found on the internet, mostly from Oracle or Wikipedia. Very little of this
More informationLecture 2: Variables and Operators. AITI Nigeria Summer 2012 University of Lagos.
Lecture 2: Variables and Operators AITI Nigeria Summer 2012 University of Lagos. Agenda Variables Types Naming Assignment Data Types Type casting Operators Declaring Variables in Java type name; Variables
More informationProgramming Lecture 3
Programming Lecture 3 Expressions (Chapter 3) Primitive types Aside: Context Free Grammars Constants, variables Identifiers Variable declarations Arithmetic expressions Operator precedence Assignment statements
More informationComputer Components. Software{ User Programs. Operating System. Hardware
Computer Components Software{ User Programs Operating System Hardware What are Programs? Programs provide instructions for computers Similar to giving directions to a person who is trying to get from point
More informationExpressions and Data Types CSC 121 Fall 2015 Howard Rosenthal
Expressions and Data Types CSC 121 Fall 2015 Howard Rosenthal Lesson Goals Understand the basic constructs of a Java Program Understand how to use basic identifiers Understand simple Java data types and
More informationJava Programming. Atul Prakash
Java Programming Atul Prakash Java Language Fundamentals The language syntax is similar to C/ C++ If you know C/C++, you will have no trouble understanding Java s syntax If you don't, it will be easier
More informationBasics of Java Programming
Basics of Java Programming Lecture 2 COP 3252 Summer 2017 May 16, 2017 Components of a Java Program statements - A statement is some action or sequence of actions, given as a command in code. A statement
More informationChapter 2. Elementary Programming
Chapter 2 Elementary Programming 1 Objectives To write Java programs to perform simple calculations To obtain input from the console using the Scanner class To use identifiers to name variables, constants,
More informationProgram Fundamentals
Program Fundamentals /* HelloWorld.java * The classic Hello, world! program */ class HelloWorld { public static void main (String[ ] args) { System.out.println( Hello, world! ); } } /* HelloWorld.java
More informationBIT Java Programming. Sem 1 Session 2011/12. Chapter 2 JAVA. basic
BIT 3383 Java Programming Sem 1 Session 2011/12 Chapter 2 JAVA basic Objective: After this lesson, you should be able to: declare, initialize and use variables according to Java programming language guidelines
More informationDM550 / DM857 Introduction to Programming. Peter Schneider-Kamp
DM550 / DM857 Introduction to Programming Peter Schneider-Kamp petersk@imada.sdu.dk http://imada.sdu.dk/~petersk/dm550/ http://imada.sdu.dk/~petersk/dm857/ OBJECT-ORIENTED PROGRAMMING IN JAVA 2 Programming
More informationLanguage Fundamentals Summary
Language Fundamentals Summary Claudia Niederée, Joachim W. Schmidt, Michael Skusa Software Systems Institute Object-oriented Analysis and Design 1999/2000 c.niederee@tu-harburg.de http://www.sts.tu-harburg.de
More informationJava Notes. 10th ICSE. Saravanan Ganesh
Java Notes 10th ICSE Saravanan Ganesh 13 Java Character Set Character set is a set of valid characters that a language can recognise A character represents any letter, digit or any other sign Java uses
More informationFull file at
Java Programming: From Problem Analysis to Program Design, 3 rd Edition 2-1 Chapter 2 Basic Elements of Java At a Glance Instructor s Manual Table of Contents Overview Objectives s Quick Quizzes Class
More informationDM503 Programming B. Peter Schneider-Kamp.
DM503 Programming B Peter Schneider-Kamp petersk@imada.sdu.dk! http://imada.sdu.dk/~petersk/dm503/! VARIABLES, EXPRESSIONS & STATEMENTS 2 Values and Types Values = basic data objects 42 23.0 "Hello!" Types
More informationCS313D: ADVANCED PROGRAMMING LANGUAGE
CS313D: ADVANCED PROGRAMMING LANGUAGE Computer Science department Lecture 2 : C# Language Basics Lecture Contents 2 The C# language First program Variables and constants Input/output Expressions and casting
More informationBASIC COMPUTATION. public static void main(string [] args) Fundamentals of Computer Science I
BASIC COMPUTATION x public static void main(string [] args) Fundamentals of Computer Science I Outline Using Eclipse Data Types Variables Primitive and Class Data Types Expressions Declaration Assignment
More informationasymptotic growth rate or order compare two functions, but ignore constant factors, small inputs
Big-Oh 1 asymptotic growth rate or order 2 compare two functions, but ignore constant factors, small inputs asymptotic growth rate or order 2 compare two functions, but ignore constant factors, small inputs
More informationVisual C# Instructor s Manual Table of Contents
Visual C# 2005 2-1 Chapter 2 Using Data At a Glance Instructor s Manual Table of Contents Overview Objectives s Quick Quizzes Class Discussion Topics Additional Projects Additional Resources Key Terms
More informationCSCI 2101 Java Style Guide
CSCI 2101 Java Style Guide Fall 2017 This document describes the required style guidelines for writing Java code in CSCI 2101. Guidelines are provided for four areas of style: identifiers, indentation,
More information5/3/2006. Today! HelloWorld in BlueJ. HelloWorld in BlueJ, Cont. HelloWorld in BlueJ, Cont. HelloWorld in BlueJ, Cont. HelloWorld in BlueJ, Cont.
Today! Build HelloWorld yourself in BlueJ and Eclipse. Look at all the Java keywords. Primitive Types. HelloWorld in BlueJ 1. Find BlueJ in the start menu, but start the Select VM program instead (you
More informationChapter 2 Elementary Programming
Chapter 2 Elementary Programming Part I 1 Motivations In the preceding chapter, you learned how to create, compile, and run a Java program. Starting from this chapter, you will learn how to solve practical
More informationUNIT- 3 Introduction to C++
UNIT- 3 Introduction to C++ C++ Character Sets: Letters A-Z, a-z Digits 0-9 Special Symbols Space + - * / ^ \ ( ) [ ] =!= . $, ; : %! &? _ # = @ White Spaces Blank spaces, horizontal tab, carriage
More informationData and Variables. Data Types Expressions. String Concatenation Variables Declaration Assignment Shorthand operators. Operators Precedence
Data and Variables Data Types Expressions Operators Precedence String Concatenation Variables Declaration Assignment Shorthand operators Review class All code in a java file is written in a class public
More informationCharacter Set. The character set of C represents alphabet, digit or any symbol used to represent information. Digits 0, 1, 2, 3, 9
Character Set The character set of C represents alphabet, digit or any symbol used to represent information. Types Uppercase Alphabets Lowercase Alphabets Character Set A, B, C, Y, Z a, b, c, y, z Digits
More informationDeclaration and Memory
Declaration and Memory With the declaration int width; the compiler will set aside a 4-byte (32-bit) block of memory (see right) The compiler has a symbol table, which will have an entry such as Identifier
More informationJava Identifiers. Java Language Essentials. Java Keywords. Java Applications have Class. Slide Set 2: Java Essentials. Copyright 2012 R.M.
Java Language Essentials Java is Case Sensitive All Keywords are lower case White space characters are ignored Spaces, tabs, new lines Java statements must end with a semicolon ; Compound statements use
More informationDM550 Introduction to Programming part 2. Jan Baumbach.
DM550 Introduction to Programming part 2 Jan Baumbach jan.baumbach@imada.sdu.dk http://www.baumbachlab.net COURSE ORGANIZATION 2 Course Elements Lectures: 10 lectures Find schedule and class rooms in online
More informationCEN 414 Java Programming
CEN 414 Java Programming Instructor: H. Esin ÜNAL SPRING 2017 Slides are modified from original slides of Y. Daniel Liang WEEK 2 ELEMENTARY PROGRAMMING 2 Computing the Area of a Circle public class ComputeArea
More informationCMPT 125: Lecture 3 Data and Expressions
CMPT 125: Lecture 3 Data and Expressions Tamara Smyth, tamaras@cs.sfu.ca School of Computing Science, Simon Fraser University January 3, 2009 1 Character Strings A character string is an object in Java,
More informationReview: Exam 1. Your First C++ Program. Declaration Statements. Tells the compiler. Examples of declaration statements
Review: Exam 1 9/20/06 CS150 Introduction to Computer Science 1 1 Your First C++ Program 1 //*********************************************************** 2 // File name: hello.cpp 3 // Author: Shereen Khoja
More informationFundamentals of Programming
Fundamentals of Programming Lecture 3 - Constants, Variables, Data Types, And Operations Lecturer : Ebrahim Jahandar Borrowed from lecturer notes by Omid Jafarinezhad Outline C Program Data types Variables
More informationWeiss Chapter 1 terminology (parenthesized numbers are page numbers)
Weiss Chapter 1 terminology (parenthesized numbers are page numbers) assignment operators In Java, used to alter the value of a variable. These operators include =, +=, -=, *=, and /=. (9) autoincrement
More informationFundamental of Programming (C)
Borrowed from lecturer notes by Omid Jafarinezhad Fundamental of Programming (C) Lecturer: Vahid Khodabakhshi Lecture 3 Constants, Variables, Data Types, And Operations Department of Computer Engineering
More informationExpressions and Data Types CSC 121 Spring 2017 Howard Rosenthal
Expressions and Data Types CSC 121 Spring 2017 Howard Rosenthal Lesson Goals Understand the basic constructs of a Java Program Understand how to use basic identifiers Understand simple Java data types
More informationUnit-II Programming and Problem Solving (BE1/4 CSE-2)
Unit-II Programming and Problem Solving (BE1/4 CSE-2) Problem Solving: Algorithm: It is a part of the plan for the computer program. An algorithm is an effective procedure for solving a problem in a finite
More informationOperators and Expressions
Operators and Expressions Conversions. Widening and Narrowing Primitive Conversions Widening and Narrowing Reference Conversions Conversions up the type hierarchy are called widening reference conversions
More informationSir Muhammad Naveed. Arslan Ahmed Shaad ( ) Muhammad Bilal ( )
Sir Muhammad Naveed Arslan Ahmed Shaad (1163135 ) Muhammad Bilal ( 1163122 ) www.techo786.wordpress.com CHAPTER: 2 NOTES:- VARIABLES AND OPERATORS The given Questions can also be attempted as Long Questions.
More informationAn overview of Java, Data types and variables
An overview of Java, Data types and variables Lecture 2 from (UNIT IV) Prepared by Mrs. K.M. Sanghavi 1 2 Hello World // HelloWorld.java: Hello World program import java.lang.*; class HelloWorld { public
More informationJAVA Programming Fundamentals
Chapter 4 JAVA Programming Fundamentals By: Deepak Bhinde PGT Comp.Sc. JAVA character set Character set is a set of valid characters that a language can recognize. It may be any letter, digit or any symbol
More informationC Language Part 1 Digital Computer Concept and Practice Copyright 2012 by Jaejin Lee
C Language Part 1 (Minor modifications by the instructor) References C for Python Programmers, by Carl Burch, 2011. http://www.toves.org/books/cpy/ The C Programming Language. 2nd ed., Kernighan, Brian,
More informationIntroduction to Programming Using Java (98-388)
Introduction to Programming Using Java (98-388) Understand Java fundamentals Describe the use of main in a Java application Signature of main, why it is static; how to consume an instance of your own class;
More informationChapter 2: Using Data
Chapter 2: Using Data Declaring Variables Constant Cannot be changed after a program is compiled Variable A named location in computer memory that can hold different values at different points in time
More informationJava language. Part 1. Java fundamentals. Yevhen Berkunskyi, NUoS
Java language Part 1. Java fundamentals Yevhen Berkunskyi, NUoS eugeny.berkunsky@gmail.com http://www.berkut.mk.ua What Java is? Programming language Platform: Hardware Software OS: Windows, Linux, Solaris,
More informationObjectives. Chapter 2: Basic Elements of C++ Introduction. Objectives (cont d.) A C++ Program (cont d.) A C++ Program
Objectives Chapter 2: Basic Elements of C++ In this chapter, you will: Become familiar with functions, special symbols, and identifiers in C++ Explore simple data types Discover how a program evaluates
More informationChapter 2: Basic Elements of C++
Chapter 2: Basic Elements of C++ Objectives In this chapter, you will: Become familiar with functions, special symbols, and identifiers in C++ Explore simple data types Discover how a program evaluates
More informationReview of the C Programming Language for Principles of Operating Systems
Review of the C Programming Language for Principles of Operating Systems Prof. James L. Frankel Harvard University Version of 7:26 PM 4-Sep-2018 Copyright 2018, 2016, 2015 James L. Frankel. All rights
More informationChapter 2: Basic Elements of C++ Objectives. Objectives (cont d.) A C++ Program. Introduction
Chapter 2: Basic Elements of C++ C++ Programming: From Problem Analysis to Program Design, Fifth Edition 1 Objectives In this chapter, you will: Become familiar with functions, special symbols, and identifiers
More informationCHAPTER 3 Expressions, Functions, Output
CHAPTER 3 Expressions, Functions, Output More Data Types: Integral Number Types short, long, int (all represent integer values with no fractional part). Computer Representation of integer numbers - Number
More informationDEPARTMENT OF MATHS, MJ COLLEGE
T. Y. B.Sc. Mathematics MTH- 356 (A) : Programming in C Unit 1 : Basic Concepts Syllabus : Introduction, Character set, C token, Keywords, Constants, Variables, Data types, Symbolic constants, Over flow,
More informationChapter 2: Data and Expressions
Chapter 2: Data and Expressions CS 121 Department of Computer Science College of Engineering Boise State University August 21, 2017 Chapter 2: Data and Expressions CS 121 1 / 51 Chapter 1 Terminology Review
More informationFall 2017 CISC124 9/16/2017
CISC124 Labs start this week in JEFF 155: Meet your TA. Check out the course web site, if you have not already done so. Watch lecture videos if you need to review anything we have already done. Problems
More informationSOFTWARE DEVELOPMENT 1. Operators 2018W A. Ferscha (Institute of Pervasive Computing, JKU Linz)
SOFTWARE DEVELOPMENT 1 Operators 2018W (Institute of Pervasive Computing, JKU Linz) OPERATORS Operators are required to form expressions. Depending on the number of operands they take, they are called:
More informationObject 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 informationOperators. Java operators are classified into three categories:
Operators Operators are symbols that perform arithmetic and logical operations on operands and provide a meaningful result. Operands are data values (variables or constants) which are involved in operations.
More informationProgramming in C++ 6. Floating point data types
Programming in C++ 6. Floating point data types! Introduction! Type double! Type float! Changing types! Type promotion & conversion! Casts! Initialization! Assignment operators! Summary 1 Introduction
More informationElementary maths for GMT. Algorithm analysis Part I
Elementary maths for GMT Algorithm analysis Part I Algorithms An algorithm is a step-by-step procedure for solving a problem in a finite amount of time Most algorithms transform input objects into output
More informationOutline and Reading. Analysis of Algorithms 1
Outline and Reading Algorithms Running time ( 3.1) Pseudo-code ( 3.2) Counting primitive operations ( 3.4) Asymptotic notation ( 3.4.1) Asymptotic analysis ( 3.4.2) Case study ( 3.4.3) Analysis of Algorithms
More informationMore Programming Constructs -- Introduction
More Programming Constructs -- Introduction We can now examine some additional programming concepts and constructs Chapter 5 focuses on: internal data representation conversions between one data type and
More informationIntroduction to C# Applications
1 2 3 Introduction to C# Applications OBJECTIVES To write simple C# applications To write statements that input and output data to the screen. To declare and use data of various types. To write decision-making
More informationThe MaSH Programming Language At the Statements Level
The MaSH Programming Language At the Statements Level Andrew Rock School of Information and Communication Technology Griffith University Nathan, Queensland, 4111, Australia a.rock@griffith.edu.au June
More information1 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 informationChapter 2: Data and Expressions
Chapter 2: Data and Expressions CS 121 Department of Computer Science College of Engineering Boise State University January 15, 2015 Chapter 2: Data and Expressions CS 121 1 / 1 Chapter 2 Part 1: Data
More informationJOSE LUIS JUAREZ VIVEROS com) has a. non-transferable license to use this Student Guide
Module 3 Identifiers, Keywords, and Types Objectives Upon completion of this module, you should be able to: Use comments in a source program Distinguish between valid and invalid identifiers Recognize
More informationIPCoreL. Phillip Duane Douglas, Jr. 11/3/2010
IPCoreL Programming Language Reference Manual Phillip Duane Douglas, Jr. 11/3/2010 The IPCoreL Programming Language Reference Manual provides concise information about the grammar, syntax, semantics, and
More informationTester vs. Controller. Elementary Programming. Learning Outcomes. Compile Time vs. Run Time
Tester vs. Controller Elementary Programming EECS1022: Programming for Mobile Computing Winter 2018 CHEN-WEI WANG For effective illustrations, code examples will mostly be written in the form of a tester
More informationCIS133J. Working with Numbers in Java
CIS133J Working with Numbers in Java Contents: Using variables with integral numbers Using variables with floating point numbers How to declare integral variables How to declare floating point variables
More informationObjects and Types. COMS W1007 Introduction to Computer Science. Christopher Conway 29 May 2003
Objects and Types COMS W1007 Introduction to Computer Science Christopher Conway 29 May 2003 Java Programs A Java program contains at least one class definition. public class Hello { public static void
More informationA Java program contains at least one class definition.
Java Programs Identifiers Objects and Types COMS W1007 Introduction to Computer Science Christopher Conway 29 May 2003 A Java program contains at least one class definition. public class Hello { public
More informationThese are reserved words of the C language. For example int, float, if, else, for, while etc.
Tokens in C Keywords These are reserved words of the C language. For example int, float, if, else, for, while etc. Identifiers An Identifier is a sequence of letters and digits, but must start with a letter.
More informationContents. Figures. Tables. Examples. Foreword. Preface. 1 Basics of Java Programming 1. xix. xxi. xxiii. xxvii. xxix
PGJC4_JSE8_OCA.book Page ix Monday, June 20, 2016 2:31 PM Contents Figures Tables Examples Foreword Preface xix xxi xxiii xxvii xxix 1 Basics of Java Programming 1 1.1 Introduction 2 1.2 Classes 2 Declaring
More information[ 11.2, 11.3, 11.4] Analysis of Algorithms. Complexity of Algorithms. 400 lecture note # Overview
400 lecture note #0 [.2,.3,.4] Analysis of Algorithms Complexity of Algorithms 0. Overview The complexity of an algorithm refers to the amount of time and/or space it requires to execute. The analysis
More informationValues and Variables 1 / 30
Values and Variables 1 / 30 Values 2 / 30 Computing Computing is any purposeful activity that marries the representation of some dynamic domain with the representation of some dynamic machine that provides
More information4. Number Representations
Educational Objectives You have a good understanding how a computer represents numbers. You can transform integers in binary representation and perform computations. You understand how the value range
More informationChapter 2: Data and Expressions
Chapter 2: Data and Expressions CS 121 Department of Computer Science College of Engineering Boise State University April 21, 2015 Chapter 2: Data and Expressions CS 121 1 / 53 Chapter 2 Part 1: Data Types
More information2 rd class Department of Programming. OOP with Java Programming
1. Structured Programming and Object-Oriented Programming During the 1970s and into the 80s, the primary software engineering methodology was structured programming. The structured programming approach
More informationOutline. Performing Computations. Outline (cont) Expressions in C. Some Expression Formats. Types for Operands
Performing Computations C provides operators that can be applied to calculate expressions: tax is 8.5% of the total sale expression: tax = 0.085 * totalsale Need to specify what operations are legal, how
More informationBuilding Java Programs. Introduction to Programming and Simple Java Programs
Building Java Programs Introduction to Programming and Simple Java Programs 1 A simple Java program public class Hello { public static void main(string[] args) { System.out.println("Hello, world!"); code
More informationElementary Programming
Elementary Programming EECS1022: Programming for Mobile Computing Winter 2018 CHEN-WEI WANG Learning Outcomes Learn ingredients of elementary programming: data types [numbers, characters, strings] literal
More informationCS 112 Introduction to Computing II. Wayne Snyder Computer Science Department Boston University
CS 112 Introduction to Computing II Wayne Snyder Department Boston University Today: Java basics: Compilation vs Interpretation Program structure Statements Values Variables Types Operators and Expressions
More informationZheng-Liang Lu Java Programming 45 / 79
1 class Lecture2 { 2 3 "Elementray Programming" 4 5 } 6 7 / References 8 [1] Ch. 2 in YDL 9 [2] Ch. 2 and 3 in Sharan 10 [3] Ch. 2 in HS 11 / Zheng-Liang Lu Java Programming 45 / 79 Example Given a radius
More informationFeatures of C. Portable Procedural / Modular Structured Language Statically typed Middle level language
1 History C is a general-purpose, high-level language that was originally developed by Dennis M. Ritchie to develop the UNIX operating system at Bell Labs. C was originally first implemented on the DEC
More information.Net Technologies. Components of.net Framework
.Net Technologies Components of.net Framework There are many articles are available in the web on this topic; I just want to add one more article over the web by explaining Components of.net Framework.
More informationIndex COPYRIGHTED MATERIAL
Index COPYRIGHTED MATERIAL Note to the Reader: Throughout this index boldfaced page numbers indicate primary discussions of a topic. Italicized page numbers indicate illustrations. A abstract classes
More informationC/C++ Programming for Engineers: Working with Integer Variables
C/C++ Programming for Engineers: Working with Integer Variables John T. Bell Department of Computer Science University of Illinois, Chicago Preview Every good program should begin with a large comment
More informationPROGRAM EFFICIENCY & COMPLEXITY ANALYSIS
Lecture 03-04 PROGRAM EFFICIENCY & COMPLEXITY ANALYSIS By: Dr. Zahoor Jan 1 ALGORITHM DEFINITION A finite set of statements that guarantees an optimal solution in finite interval of time 2 GOOD ALGORITHMS?
More informationLECTURE 3 C++ Basics Part 2
LECTURE 3 C++ Basics Part 2 OVERVIEW Operators Type Conversions OPERATORS Operators are special built-in symbols that have functionality, and work on operands. Operators are actually functions that use
More informationLanguage Reference Manual simplicity
Language Reference Manual simplicity Course: COMS S4115 Professor: Dr. Stephen Edwards TA: Graham Gobieski Date: July 20, 2016 Group members Rui Gu rg2970 Adam Hadar anh2130 Zachary Moffitt znm2104 Suzanna
More informationComputer System and programming in C
1 Basic Data Types Integral Types Integers are stored in various sizes. They can be signed or unsigned. Example Suppose an integer is represented by a byte (8 bits). Leftmost bit is sign bit. If the sign
More informationLanguage Reference Manual
Programming Languages and Translators Language Reference Manual ART: Animation Rendering Tool Brett Jervey - baj2125 Gedion Metaferia - gym2103 Natan Kibret - nfk2105 Soul Joshi - srj2120 October 26, 2016
More informationData Types, Variables and Arrays. OOC 4 th Sem, B Div Prof. Mouna M. Naravani
Data Types, Variables and Arrays OOC 4 th Sem, B Div 2016-17 Prof. Mouna M. Naravani Identifiers in Java Identifiers are the names of variables, methods, classes, packages and interfaces. Identifiers must
More informationJava enum, casts, and others (Select portions of Chapters 4 & 5)
Enum or enumerates types Java enum, casts, and others (Select portions of Chapters 4 & 5) Sharma Chakravarthy Information Technology Laboratory (IT Lab) Computer Science and Engineering Department The
More informationReview of the C Programming Language
Review of the C Programming Language Prof. James L. Frankel Harvard University Version of 11:55 AM 22-Apr-2018 Copyright 2018, 2016, 2015 James L. Frankel. All rights reserved. Reference Manual for the
More information