Information Science 1


 Debra Charles
 2 years ago
 Views:
Transcription
1 Information Science 1 Simple Calcula,ons Week 09 College of Information Science and Engineering Ritsumeikan University
2 Topics covered l Terms and concepts from Week 8 l Simple calculations Documenting programs white spaces comment statements Expressions Arithmetic operators and arithmetic operator precedence Mixedtype arithmetic and type casting Shortcut operators l Quiz 2
3 Recall Week 08 l Compiler, interpreter l Type, data type, ADT l Declaration l Variable l Constant l Literal l Integer, float, char, boolean l Identifier l Assignment statement 3
4 Our goals today l To realize the importance of documenting the source code l To understand how to correctly do arithmetic with computers, using highlevel programming languages l To understand arithmetic operator precedence 4
5 White space l To increase readability of your code, surround operators and operands with white space and skip lines between logical sections of program l Space, tab, and new line are white space characters At least one white space character is required between a keyword (reserved word, operator) and identifier Any amount of white space characters are permitted between identifiers, keywords, operators, and literals 5
6 Comment statements l Comment statements (comments) explain the program to yourself and others There are two types of comments: Block comments Can span several lines Begin with /* and end with */ The compiler ignores everything from /* to */ Line comments Start with // The compiler ignores text from // to the end of line 6
7 Documenting programs l Always include a block comment at the beginning of each source file (new program) identify the author of the program briefly describe the function of the program l Use line and block comments to explain the logic of the program (for example include pseudocode) always explain constants used (there must be no unexplained magic coefficients ) explain algorithm by default assumptions always explain the program I/O (interface) 7
8 l Recall assignment statements: <left side> = <right side> Expressions l An expression is a combination of one or more operators and operands that evaluate to a single value, such that: the value is assigned to left side left side is (must be) a single variable or named constant The value must be compatible with (convertible to) the left side s data type 8
9 Arithmetic expressions l Arithmetic expressions compute numeric results and make use of the arithmetic operators: Operator Operation + addition  subtraction * multiplication / division % modulus (remainder after division) 9
10 Division and remainder If both operands to the division operator / are integers, the result is an integer (the fractional part is discarded), e.g. 14 / 3 equals to 8 / 12 equals to The remainder modulus operator % (or MOD ) returns the remainder after dividing the first operand by the second, e.g. 14 % 3 equals to 2 8 % 12 equals to 8 Taking modulus is an integer operation both operands must be integers
11 % usage examples l Remainder operator is very useful in programming. For example: for any even number q, q % 2 is always 0, and for any odd number p, p % 2 is always 1 l Another example: Suppose we know that January 1 is Saturday. We can then easily calculate that the day for February 1 is Tuesday: Saturday is the 6 th day in a week (Sunday is 0 th ) January has 31 days A week has 7 days All this can be written as: (6+31)%7 that gives 2, the second day in a week which is Tuesday 11
12 Division by zero l Integer division by 0: Example: int x = 4 / 0; l This will result in no compiler error, but at run time, ArithmeticException message (fatal error) will be generated, and the program will stop executing l Floatingpoint division by 0: If dividend is not 0, the result is Infinity If dividend and divisor are both 0, the result is NaN (not a number) 12
13 Operator precedence Precedence Operator Order of evaluation Operation 1 ( ) parenthesis for explicit grouping 2 * / % left  right multiplication, division, modulus left  right addition, subtraction last = right  left assignment Example: x = a / b * (c + (d  e))
14 Expression trees l Sometimes, the evaluation of an expression is convenient to show using an expression tree l The operators lower in the tree have higher precedence for that expression, e.g. a + (b c) / d + a / d b c 14
15 l In most programming languages, when performing calculations with operands of different data types (on right side): Lowerprecision operands are promoted to higherprecision data types, then the calculation is performed Promotion is effective only for expression evaluation and does not cause a permanent change to the data This is called "implicit type casting" l Any expression involving a floatingpoint operand will have a floatingpoint result (on right side) 15 Mixedtype arithmetic
16 16 Rules of promotion Applies the first of these rules that fits: 1. If either operand is a double, the other operand is converted to a double 2. If either operand is a float, the other operand is converted to a float 3. If either operand is a long, the other operand is converted to a long 4. If either operand is an int, the other operand is promoted to an int 5. If neither operand is a double, float, long, or an int, both operands are promoted to int
17 Examples of promotion int x,y; // integers are 4 bytes using 2's compliment format short z; // shorts are 2 bytes using 2's compliment format float a; // floats are 4 bytes, using floating point format x = 7; z = 3; a = 3.14; y = a * 2 + x/z; Explanation: a = 3.14 (floating point number) '2' is integer but is promoted to '2.0' a floating point number z is a short and will be promoted to an integer x/z involves only integers (7/3) so will give a result of 2 (an integer) then the integer 2 will be promoted to 2.0 (a floating point number) calculation: 3.14 * = 8.28 (a floating point number) finally y is assigned an integer 8 since y is an integer data type (the fractional part is removed) 17
18 18 Explicit type casting l Syntax: (datatype)( expression ) l Examples: float x = (float)5/(float)2; int c = (int)(x 3); l Note that parentheses around an expression with no operators have no effect l Casts are useful for calculating averages (think: why?)
19 Shortcut operators l ++ is increment by 1, and  is decrement by 1. Examples: count++; // count = count + 1; count; // count = count  1; l Postfix version (var++, var): use value of var in expression, then increment or decrement l Prefix version (++var, var): increment or decrement var, then use its value in expression 19
20 Examples of shortcuts int x,y,z; x = 2; y = 5; z = x++ + y; // first z is 7; then x = 3 x = 2; y = 5; z = ++x + y; // first x = 3; then z is 8 x = 2; y = 5; z = x y + y/2; /* is y incremented by ++y before or after y is read for the evaluation of y/2? The result is undefined! */ 20
21 Note that no spaces are allowed between the arithmetic operator and the equals sign 21 Other shortcut operators Operator Example Equivalent += a += 3; a = a + 3; = a = 10; a = a  10; *= a *= 4; a = a * 4; /= a /= 7; a = a / 7; %= a %= 10; a = a % 10;
22 22 Operator precedence Precedence 1 ( ) Operator Order of evaluation Operation parenthesis for grouping left  right postincrement, postdecrement right  left preincrement, predecrement 3 * / % left  right multiplication, division, modulus left  right addition or String concatenation, subtraction 5 = += = *= /= %= right  left assignment
23 Real example: C99 operator precedence Precedence Operator Description Associativity Suffix/postfix increment and decrement Lefttoright ( ) Function call [ ] Array subscripting. > Structure and union member access ( type ) { list } Compound literal(c99) Prefix increment and decrement Righttoleft +  Unary plus and minus! ~ Logical NOT and bitwise NOT (type) Type cast * Indirection (dereference) & Addressof sizeof Sizeof 3 * / % Multiplication, division, and remainder Lefttoright Addition and subtraction 5 << >> Bitwise left shift and right shift 6 < <= > >= Relational operators (inequalities) 7 ==!= Relational operators (equalities) 8 & Bitwise AND 9 ^ Bitwise XOR (exclusive or) 10 Bitwise OR (inclusive or) 11 && Logical AND 12 Logical OR 13?: Ternary conditional RighttoLeft 14 = Simple assignment += = Assignment by sum and difference *= /= %= Assignment by product, quotient, and remainder <<= >>= Assignment by bitwise left shift and right shift &= ^= = Assignment by bitwise AND, XOR, and OR 15, Comma Lefttoright 23
24 24 Concepts you need to know after this class l White spaces and comment statements: Why we do need to document programs l Arithmetic expressions: Operators and operator precedence (including shortcuts) l Mixedtype arithmetic rules and type casting
25 25 l Read these slides again l Do the selfpreparation assignments l Learn the vocabulary Homework l Consult, whenever necessary, the textbook materials
26 26 Next class l Boolean expressions Binary logic Relational and logical operators Operator precedence Boolean and algebraic expressions
27 Quiz 04 27
Information Science 1
Topics covered Information Science 1 Terms and concepts from Week 8 Simple calculations Documenting programs Simple Calcula,ons Expressions Arithmetic operators and arithmetic operator precedence Mixedtype
More informationExpressions and Precedence. Last updated 12/10/18
Expressions and Precedence Last updated 12/10/18 Expression: Sequence of Operators and Operands that reduce to a single value Simple and Complex Expressions Subject to Precedence and Associativity Six
More informationModule 2  Part 2 DATA TYPES AND EXPRESSIONS 1/15/19 CSE 1321 MODULE 2 1
Module 2  Part 2 DATA TYPES AND EXPRESSIONS 1/15/19 CSE 1321 MODULE 2 1 Topics 1. Expressions 2. Operator precedence 3. Shorthand operators 4. Data/Type Conversion 1/15/19 CSE 1321 MODULE 2 2 Expressions
More informationUNIT 3 Introduction to C++
UNIT 3 Introduction to C++ C++ Character Sets: Letters AZ, az Digits 09 Special Symbols Space +  * / ^ \ ( ) [ ] =!= . $, ; : %! &? _ # = @ White Spaces Blank spaces, horizontal tab, carriage
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 informationWill introduce various operators supported by C language Identify supported operations Present some of terms characterizing operators
Operators Overview Will introduce various operators supported by C language Identify supported operations Present some of terms characterizing operators Operands and Operators Mathematical or logical relationships
More informationOperators in C. Staff Incharge: S.Sasirekha
Operators in C Staff Incharge: S.Sasirekha Operators An operator is a symbol which helps the user to command the computer to do a certain mathematical or logical manipulations. Operators are used in C
More informationBasic operators, Arithmetic, Relational, Bitwise, Logical, Assignment, Conditional operators. JAVA Standard Edition
Basic operators, Arithmetic, Relational, Bitwise, Logical, Assignment, Conditional operators JAVA Standard Edition Java  Basic Operators Java provides a rich set of operators to manipulate variables.
More informationCprE 288 Introduction to Embedded Systems Exam 1 Review. 1
CprE 288 Introduction to Embedded Systems Exam 1 Review http://class.ece.iastate.edu/cpre288 1 Overview of Today s Lecture Announcements Exam 1 Review http://class.ece.iastate.edu/cpre288 2 Announcements
More informationA complex expression to evaluate we need to reduce it to a series of simple expressions. E.g * 7 =>2+ 35 => 37. E.g.
1.3a Expressions Expressions An Expression is a sequence of operands and operators that reduces to a single value. An operator is a syntactical token that requires an action be taken An operand is an object
More informationSECTION II: LANGUAGE BASICS
Chapter 5 SECTION II: LANGUAGE BASICS Operators Chapter 04: Basic Fundamentals demonstrated declaring and initializing variables. This chapter depicts how to do something with them, using operators. Operators
More informationInformatics Ingeniería en Electrónica y Automática Industrial
Informatics Ingeniería en Electrónica y Automática Industrial Operators and expressions in C Operators and expressions in C Numerical expressions and operators Arithmetical operators Relational and logical
More informationInformation Science 1
Information Science Boolean Expressions Week College of Information Science and Engineering Ritsumeikan University Topics covered l Terms and concepts from Week 9 l Binary (Boolean) logic History Boolean
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 informationGO  OPERATORS. This tutorial will explain the arithmetic, relational, logical, bitwise, assignment and other operators one by one.
http://www.tutorialspoint.com/go/go_operators.htm GO  OPERATORS Copyright tutorialspoint.com An operator is a symbol that tells the compiler to perform specific mathematical or logical manipulations.
More informationOperators & Expressions
Operators & Expressions Operator An operator is a symbol used to indicate a specific operation on variables in a program. Example : symbol + is an add operator that adds two data items called operands.
More informationA flow chart is a graphical or symbolic representation of a process.
Q1. Define Algorithm with example? Answer: A sequential solution of any program that written in human language, called algorithm. Algorithm is first step of the solution process, after the analysis of
More informationUnit 3. Operators. School of Science and Technology INTRODUCTION
INTRODUCTION Operators Unit 3 In the previous units (unit 1 and 2) you have learned about the basics of computer programming, different data types, constants, keywords and basic structure of a C program.
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 informationIn Fig. 3.5 and Fig. 3.7, we include some completely blank lines in the pseudocode for readability. programs into their various phases.
Formulating Algorithms with TopDown, Stepwise Refinement Case Study 2: SentinelControlled Repetition In Fig. 3.5 and Fig. 3.7, we include some completely blank lines in the pseudocode for readability.
More informationComputers Programming Course 6. Iulian Năstac
Computers Programming Course 6 Iulian Năstac Recap from previous course Data types four basic arithmetic type specifiers: char int float double void optional specifiers: signed, unsigned short long 2 Recap
More informationJAVA OPERATORS GENERAL
JAVA OPERATORS GENERAL Java provides a rich set of operators to manipulate variables. We can divide all the Java operators into the following groups: Arithmetic Operators Relational Operators Bitwise Operators
More informationOperators and Expressions in C & C++ Mahesh Jangid Assistant Professor Manipal University, Jaipur
Operators and Expressions in C & C++ Mahesh Jangid Assistant Professor Manipal University, Jaipur Operators and Expressions 8/24/2012 Dept of CS&E 2 Arithmetic operators Relational operators Logical operators
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 informationFundamentals of Programming Session 7
Fundamentals of Programming Session 7 Instructor: Reza EntezariMaleki Email: entezari@ce.sharif.edu 1 Fall 2014 These slides have been created using Deitel s slides Sharif University of Technology Outlines
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 informationIntroduction. Following are the types of operators: Unary requires a single operand Binary requires two operands Ternary requires three operands
Introduction Operators are the symbols which operates on value or a variable. It tells the compiler to perform certain mathematical or logical manipulations. Can be of following categories: Unary requires
More informationChapter 12 Variables and Operators
Chapter 12 Variables and Operators Highlights (1) r. height width operator area = 3.14 * r *r + width * height literal/constant variable expression (assignment) statement 122 Highlights (2) r. height
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 informationChapter 3: Operators, Expressions and Type Conversion
101 Chapter 3 Operators, Expressions and Type Conversion Chapter 3: Operators, Expressions and Type Conversion Objectives To use basic arithmetic operators. To use increment and decrement operators. To
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 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 informationJava provides a rich set of operators to manipulate variables. We can divide all the Java operators into the following groups:
Basic Operators Java provides a rich set of operators to manipulate variables. We can divide all the Java operators into the following groups: Arithmetic Operators Relational Operators Bitwise Operators
More informationFull file at
Java Programming: From Problem Analysis to Program Design, 3 rd Edition 21 Chapter 2 Basic Elements of Java At a Glance Instructor s Manual Table of Contents Overview Objectives s Quick Quizzes Class
More informationOperators. Lecture 3 COP 3014 Spring January 16, 2018
Operators Lecture 3 COP 3014 Spring 2018 January 16, 2018 Operators Special builtin symbols that have functionality, and work on operands operand an input to an operator Arity  how many operands an operator
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 informationVisual C# Instructor s Manual Table of Contents
Visual C# 2005 21 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 informationPART II. Computation
PART II Computation 72 Chapter 4 Expressions Computation is central to computer programming. We discuss how the usual mathematical operations can be applied to variables and introduce the concepts of precedence
More informationSlide 1 CS 170 Java Programming 1 Expressions Duration: 00:00:41 Advance mode: Auto
CS 170 Java Programming 1 Expressions Slide 1 CS 170 Java Programming 1 Expressions Duration: 00:00:41 What is an expression? Expression Vocabulary Any combination of operators and operands which, when
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 informationCOSC 236 Section 101 Computer Science 1  Prof. Michael A. Soderstrand
COSC 236 Section 101 Computer Science 1  Prof. Michael A. Soderstrand COSC 236 Web Site I have decided to keep this site for the whole semester I still hope to have blackboard up and running, but you
More information3. EXPRESSIONS. It is a sequence of operands and operators that reduce to a single value.
3. EXPRESSIONS It is a sequence of operands and operators that reduce to a single value. Operator : It is a symbolic token that represents an action to be taken. Ex: * is an multiplication operator. Operand:
More informationOperators and Expressions:
Operators and Expressions: Operators and expression using numeric and relational operators, mixed operands, type conversion, logical operators, bit operations, assignment operator, operator precedence
More informationExpressions. Arithmetic expressions. Logical expressions. Assignment expression. n Variables and constants linked with operators
Expressions 1 Expressions n Variables and constants linked with operators Arithmetic expressions n Uses arithmetic operators n Can evaluate to any value Logical expressions n Uses relational and logical
More informationOperators and Type Conversion. By Avani M. Sakhapara Assistant Professor, IT Dept, KJSCE
Operators and Type Conversion By Avani M. Sakhapara Assistant Professor, IT Dept, KJSCE Introduction An operator is a symbol which represents a particular operation that can be performed on some data.
More informationDeclaration and Memory
Declaration and Memory With the declaration int width; the compiler will set aside a 4byte (32bit) block of memory (see right) The compiler has a symbol table, which will have an entry such as Identifier
More informationQUIZ: What value is stored in a after this
QUIZ: What value is stored in a after this statement is executed? Why? a = 23/7; QUIZ evaluates to 16. Lesson 4 Statements, Expressions, Operators Statement = complete instruction that directs the computer
More informationECE 122 Engineering Problem Solving with Java
ECE 122 Engineering Problem Solving with Java Lecture 3 Expression Evaluation and Program Interaction Outline Problem: How do I input data and use it in complicated expressions Creating complicated expressions
More informationLESSON 1. A C program is constructed as a sequence of characters. Among the characters that can be used in a program are:
LESSON 1 FUNDAMENTALS OF C The purpose of this lesson is to explain the fundamental elements of the C programming language. C like other languages has all alphabet and rules for putting together words
More informationDepartment of Computer Science
Department of Computer Science Definition An operator is a symbol (+,,*,/) that directs the computer to perform certain mathematical or logical manipulations and is usually used to manipulate data and
More informationChapter 3 Structure of a C Program
Chapter 3 Structure of a C Program Objectives To be able to list and describe the six expression categories To understand the rules of precedence and associativity in evaluating expressions To understand
More informationOperators in java Operator operands.
Operators in java Operator in java is a symbol that is used to perform operations and the objects of operation are referred as operands. There are many types of operators in java such as unary operator,
More informationChapter 7. Expressions and Assignment Statements ISBN
Chapter 7 Expressions and Assignment Statements ISBN 0321330250 Chapter 7 Topics Introduction Arithmetic Expressions Overloaded Operators Type Conversions Relational and Boolean Expressions ShortCircuit
More informationPart I Part 1 Expressions
Writing Program in C Expressions and Control Structures (Selection Statements and Loops) Jan Faigl Department of Computer Science Faculty of Electrical Engineering Czech Technical University in Prague
More informationWriting Program in C Expressions and Control Structures (Selection Statements and Loops)
Writing Program in C Expressions and Control Structures (Selection Statements and Loops) Jan Faigl Department of Computer Science Faculty of Electrical Engineering Czech Technical University in Prague
More informationLECTURE 3 C++ Basics Part 2
LECTURE 3 C++ Basics Part 2 OVERVIEW Operators Type Conversions OPERATORS Operators are special builtin symbols that have functionality, and work on operands. Operators are actually functions that use
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 informationME 461 C review Session Fall 2009 S. Keres
ME 461 C review Session Fall 2009 S. Keres DISCLAIMER: These notes are in no way intended to be a complete reference for the C programming material you will need for the class. They are intended to help
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 informationData Types and Variables in C language
Data Types and Variables in C language Disclaimer The slides are prepared from various sources. The purpose of the slides is for academic use only Operators in C C supports a rich set of operators. Operators
More informationCSCI 2010 Principles of Computer Science. Data and Expressions 08/09/2013 CSCI
CSCI 2010 Principles of Computer Science Data and Expressions 08/09/2013 CSCI 2010 1 Data Types, Variables and Expressions in Java We look at the primitive data types, strings and expressions that are
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 informationLe L c e t c ur u e e 2 To T p o i p c i s c t o o b e b e co c v o e v r e ed e Variables Operators
Course Name: Advanced Java Lecture 2 Topics to be covered Variables Operators Variables Introduction A variables can be considered as a name given to the location in memory where values are stored. One
More informationFull file at
Java Programming, Fifth Edition 21 Chapter 2 Using Data within a Program At a Glance Instructor s Manual Table of Contents Overview Objectives Teaching Tips Quick Quizzes Class Discussion Topics Additional
More informationXC Specification. 1 Lexical Conventions. 1.1 Tokens. The specification given in this document describes version 1.0 of XC.
XC Specification IN THIS DOCUMENT Lexical Conventions Syntax Notation Meaning of Identifiers Objects and Lvalues Conversions Expressions Declarations Statements External Declarations Scope and Linkage
More informationProgramming in C++ 5. Integral data types
Programming in C++ 5. Integral data types! Introduction! Type int! Integer multiplication & division! Increment & decrement operators! Associativity & precedence of operators! Some common operators! Long
More informationExpressions & Assignment Statements
Expressions & Assignment Statements 1 Topics Introduction Arithmetic Expressions Overloaded Operators Type Conversions Relational and Boolean Expressions ShortCircuit Evaluation Assignment Statements
More informationExpression and Operator
Expression and Operator Examples: Two types: Expressions and Operators 3 + 5; x; x=0; x=x+1; printf("%d",x); Function calls The expressions formed by data and operators An expression in C usually has a
More informationProgramming I Lecture 7
. Definition: An integer is a number without a fractional part. The set of integers is the union of the set of whole numbers and the set of negative counting numbers... Integers and whole numbers. C++
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 informationESCI 386 IDL Programming for Advanced Earth Science Applications Lesson 1 IDL Operators
ESCI 386 IDL Programming for Advanced Earth Science Applications Lesson 1 IDL Operators ARITHMATIC OPERATORS The assignment operator in IDL is the equals sign, =. IDL uses all the familiar arithmetic operators
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 informationCSC 1214: ObjectOriented Programming
CSC 1214: ObjectOriented Programming J. Kizito Makerere University email: jkizito@cis.mak.ac.ug www: http://serval.ug/~jona materials: http://serval.ug/~jona/materials/csc1214 elearning environment:
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 informationChapter 2 Using Data. Instructor s Manual Table of Contents. At a Glance. Overview. Objectives. Teaching Tips. Quick Quizzes. Class Discussion Topics
Java Programming, Sixth Edition 21 Chapter 2 Using Data At a Glance Instructor s Manual Table of Contents Overview Objectives Teaching Tips Quick Quizzes Class Discussion Topics Additional Projects Additional
More informationBasics of Programming
Unit 2 Basics of Programming Problem Analysis When we are going to develop any solution to the problem, we must fully understand the nature of the problem and what we want the program to do. Without the
More informationBasic Operations jgrasp debugger Writing Programs & Checkstyle
Basic Operations jgrasp debugger Writing Programs & Checkstyle Suppose you wanted to write a computer game to play "Rock, Paper, Scissors". How many combinations are there? Is there a tricky way to represent
More informationJava How to Program, 9/e. Copyright by Pearson Education, Inc. All Rights Reserved.
Java How to Program, 9/e Copyright 19922012 by Pearson Education, Inc. All Rights Reserved. Copyright 19922012 by Pearson Copyright 19922012 by Pearson Before writing a program to solve a problem, have
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 informationChapter 3 Structured Program Development in C Part II
Chapter 3 Structured Program Development in C Part II C How to Program, 8/e, GE 2016 Pearson Education, Ltd. All rights reserved. 1 3.7 The while Iteration Statement An iteration statement (also called
More informationCOMP Primitive and Class Types. Yi Hong May 14, 2015
COMP 110001 Primitive and Class Types Yi Hong May 14, 2015 Review What are the two major parts of an object? What is the relationship between class and object? Design a simple class for Student How to
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 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 informationChapter 7. Expressions and Assignment Statements
Chapter 7 Expressions and Assignment Statements Chapter 7 Topics Introduction Arithmetic Expressions Overloaded Operators Type Conversions Relational and Boolean Expressions ShortCircuit Evaluation Assignment
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 informationEngineering Computing I
Engineering Computing I Types, Operators, and Expressions Types Operators Expressions 2 1 2.1 Variable Names Names are made up of letters and digits The first character must be a letter The underscore
More informationArithmetic Operators. Portability: Printing Numbers
Arithmetic Operators Normal binary arithmetic operators: +  * / Modulus or remainder operator: % x%y is the remainder when x is divided by y well defined only when x > 0 and y > 0 Unary operators:  +
More informationChapter 7. Expressions and Assignment Statements (updated edition 11) ISBN
Chapter 7 Expressions and Assignment Statements (updated edition 11) ISBN 0321493621 Chapter 7 Topics Introduction Arithmetic Expressions Overloaded Operators Type Conversions Relational and Boolean
More informationISA 563 : Fundamentals of Systems Programming
ISA 563 : Fundamentals of Systems Programming Variables, Primitive Types, Operators, and Expressions September 4 th 2008 Outline Define Expressions Discuss how to represent data in a program variable name
More informationUNIT 3 OPERATORS. [Marks 12]
1 UNIT 3 OPERATORS [Marks 12] SYLLABUS 2 INTRODUCTION C supports a rich set of operators such as +, , *,,
More informationChapter 12 Variables and Operators
Chapter 12 Variables and Operators Basic C Elements Variables Named, typed data items Operators Predefined actions performed on data items Combined with variables to form expressions, statements Statements
More informationChapter 2 Primitive Data Types and Operations. Objectives
Chapter 2 Primitive Data Types and Operations Prerequisites for Part I Basic computer skills such as using Windows, Internet Explorer, and Microsoft Word Chapter 1 Introduction to Computers, Programs,
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 4Sep2018 Copyright 2018, 2016, 2015 James L. Frankel. All rights
More informationUnit2 (Operators) ANAND KR.SRIVASTAVA
Unit2 (Operators) ANAND KR.SRIVASTAVA 1 Operators in C ( use of operators in C ) Operators are the symbol, to perform some operation ( calculation, manipulation). Set of Operations are used in completion
More informationOverview of C. Basic Data Types Constants Variables Identifiers Keywords Basic I/O
Overview of C Basic Data Types Constants Variables Identifiers Keywords Basic I/O NOTE: There are six classes of tokens: identifiers, keywords, constants, string literals, operators, and other separators.
More informationInfix to Postfix Conversion
Infix to Postfix Conversion Infix to Postfix Conversion Stacks are widely used in the design and implementation of compilers. For example, they are used to convert arithmetic expressions from infix notation
More informationPrepared by: Shraddha Modi
Prepared by: Shraddha Modi Introduction Operator: An operator is a symbol that tells the Computer to perform certain mathematical or logical manipulations. Expression: An expression is a sequence of operands
More informationProf. Navrati Saxena TA: Rochak Sachan
JAVA Prof. Navrati Saxena TA: Rochak Sachan Operators Operator Arithmetic Relational Logical Bitwise 1. Arithmetic Operators are used in mathematical expressions. S.N. 0 Operator Result 1. + Addition 6.
More informationCIS 110: Introduction to Computer Programming
CIS 110: Introduction to Computer Programming Lecture 3 Express Yourself ( 2.1) 9/16/2011 CIS 110 (11fa)  University of Pennsylvania 1 Outline 1. Data representation and types 2. Expressions 9/16/2011
More information