Operators. Java operators are classified into three categories:


 Alexandra Gilbert
 4 years ago
 Views:
Transcription
1 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. Operands of an operator are always evaluated from left to the right. Java operators are classified into three categories: Unary operator Binary operator Ternary operator (conditional operator) These operators operate on only one operand These operators operate on two operands These operators operate on three operands. The value returned by the expression depends upon a condition. Arithmetic operators: These are used to perform basic mathematical calculations. There are two types of arithmetic operator: Binary arithmetic operators (need two operands to perform calculation.) Addition + Subtraction  Multiplication * Division / Remainder % Adds values of its operands Subtracts values of its operands Multiplies values of its operands Divides the first operand by the second. Displays the quotient Finds the modulus of its first operand relative to the second. Displays the remained. Unary arithmetic Operators ( operators that act on one operand) Unary + Unary  This operator precedes an operand. The operands must have arithmetic type and the result is the value of the argument. This operator proceeds an operand. The operands must have arithmetic type and the result is the negation of its operand s value. ( 1 )
2 Increment (++) / Decrement Operators( ) These are used to increase or decrease the value stored in a variable by 1 respectively. The operator ++ adds 1 to its operand. The operator   Subtracts 1 from its operand. These operators can be used both as a prefix and as a suffix. Prefix Increment (++x) Postfix Increment (x++) Prefix Decrement ( x) Postfix Decrement (x ) When an increment operator precedes an operand, it is prefix increment. It increases the value of operand by 1 and then evaluates the expression. When an increment operator follows its operand, it is postfix increment. It evaluates the expression, and then increases the value of operand by 1 It decreases the value of operand by 1 and then evaluates the expression. It evaluates the expression, and then decreases the value of operand by 1 Relational Operator These are used to show the relationship between the operands. These operators compare the values of variables and determine the result in the Boolean expression format (true/false). These operators have lower precedence than arithmetic operators, but a higher precedence than the assignment operator. Operator Greater than > Less than < Greater than or equal to >= Less than or equal to <= Equal to = = Not equal to!= Symbol Logical Operator These are used to construct more complex decision making expressions. They provide result in the form of true or false, depending upon the evaluation of different relational expressions. ( 2 )
3 Java supports five binary and one unary logical operators: Operator Use Description && op1 && op2 Returns true if op1 and op2 are both true. It has lower precedence than the relational operators. op1 op2 Returns true if either op1 or op2 is true. It has lower precedence than the relational operators.!! op It works on single expression or operand. It is a unary operator. It reverse the result of the expression following it. It has higher precedence than any of the relational or arithmetic operators. Bitwise Operators Bitwise operators are special types of operators, which perform manipulations on binary data (bits). These are used for addition, multiplication, shifting and negating the binary data. These are also called binary operators as they are based on Boolean algebra. They work only with byte, short, int and long type operands. Java provides four Bitwise operators: Operators & Meaning Bitwise AND Bitwise OR ^ Bitwise XOR (exclusive OR) ~ Bitwise complement Assignment Operator ( = ) It is used to assign a value of an expression to a variable. It assigns the value on its right side to the variable written on the left of it. If we try to assign a new value to an operand, which already contains some value, then the existing value will be replaced by the new one. Syntax: variable = expression; Java Shorthand assignment Operators: Operator Expression Shorthand assignment expression + = a=a+1 a+=1 ( 3 )
4 = a=a1 a=1 *= a=a*n a*=n /= a=a/n a/=n %= a=a%n a%=n = a=a n a =n ^= a=a^n a^=n <<= a=a<<n a<<=n >>= a=a>>n a>>=n >>>= a=a>>>n a>>>=n Ternary Operator(?:) (Conditional Operator) This operator needs three operands to perform an operation. Syntax: variable=<test expression>?<expression1>:<expression2>; Test expression1 is evaluated first. If it evaluates to true then the variable contains the value of expression1, otherwise it will contain the value of expression 2. Conditional operator has lower precedence than most of the operators. Special Operators The [ ] operator The. operator The ( ) operator The type operator The new operator Instanceof operator (Object reference) The square brackets are used to declare arrays, to create arrays and to access a particular element in an array. The dot operator accesses instant members of an object or class members of a class When declaring or calling a method, the method s arguments are listed between parenthesis( ). One can also pass an empty argument. This operator casts or converts a value in a variable to the specified type. Used to create a new object or a new array. It is used to check whether the object belongs to a particular class. It returns the value true if its first operand is an instance of its second. ( 4 )
5 Operator precedence Operator precedence determines the order in which expressions are evaluated. Java Operator Precedence Table Precedence Operator Type Associativity () [] Parentheses Array subscript Member selection Left to Right High precedence Unary postincrement Unary postdecrement Right to left ! ~ ( type ) Unary preincrement Unary predecrement Unary plus Unary minus Unary logical negation Unary bitwise complement Unary type cast Right to left * / % Multiplication Division Modulus +  Addition Subtraction << >> >>> Bitwise left shift Bitwise right shift with sign extension Bitwise right shift with zero extension < <= > >= instanceof Relational less than Relational less than or equal Relational greater than Relational greater than or equal Type comparison (objects only) ==!= Relational is equal to Relational is not equal to & Bitwise AND ^ Bitwise exclusive OR Bitwise inclusive OR ( 5 )
6 && Logical AND Logical OR? : Ternary conditional Right to left = += = *= /= %= Assignment Addition assignment Subtraction assignment Multiplication assignment Division assignment Modulus assignment Right to left Expressions An expression in Java is a valid combination of operators, constants and variables i.e. a legal combination of JAVA TOKENS. The type of operators used in an expression determine the expression type. An expression is composed of one or more operands and returns a value as a result. An expression can be mathematical, relational (or logical) or it could be a compound expression depending upon the result it produces. Arithmetic Expressions: These can either be pure integer expressions or pure real expressions. Sometimes a mixed expression can also be formed which is a mixture of real and integer expressions. An arithmetic expression may include variables, constants and arithmetic operators to provide a meaningful result. a. Pure Arithmetic Expression: An expression that has all operands of same data type. These expressions can be pure integer or pure real. Here all operands are of the same type. b. Mixed Arithmetic Expression: If an expression contains both integer and real values, then it is a mixed arithmetic expression. Here operands are of mixed or different data type. Boolean Expressions: Evaluations of expressions that result into true or false are called Boolean expressions. These expressions are valid combinations of constants, variables, relational and logical operators. ( 6 )
7 Statements Statements direct the computer to perform an action. They can alter the value of variables, process input, generate output or respond to user mouse or keyboard actions. Statements are the smallest executable unit and are always terminated with a semi colon. Java Statements: o Expression Statements: These are valid Java expressions which are terminated by a semicolon. Assignment expressions e.g: a=5; Any use of ++ or   e.g: i++, i ; Method calls e.g: System.out.println( Statement ); Object creation expressions e.g: School grade=new(school); o Assignment Statement: It is used to assign a value to a variable on the left of equals sign(=) with the value of expression given on the right side of equals sign. Declaration Statement: It is used to declare a variable. Control Statement: It is used to control the flow of a program.(if, ifelse,for,while break etc.) o Null Statement(;) :The simplest statement in Java is the empty or null statement. It is written as a single semicolon. It can be used to indicate an empty loop. o Compound Statement: This is a sequence of statements grouped together within a pair of curly braces{ }. o Block Statement: A block is a group of zero or more statements between the braces and can be used anywhere in the program. ( 7 )
Basic 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 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 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 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 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 informationThe Arithmetic Operators. Unary Operators. Relational Operators. Examples of use of ++ and
The Arithmetic Operators The arithmetic operators refer to the standard mathematical operators: addition, subtraction, multiplication, division and modulus. Op. Use Description + x + y adds x and y x y
More informationThe Arithmetic Operators
The Arithmetic Operators The arithmetic operators refer to the standard mathematical operators: addition, subtraction, multiplication, division and modulus. Examples: Op. Use Description + x + y adds x
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 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 informationJava provides a rich set of operators to manipulate variables. We can divide all the Java operators into the following groups:
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 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 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 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 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 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 informationJava provides a rich set of operators to manipulate variables. We can divide all the Java operators into the following g roups:
JAVA BASIC OPERATORS http://www.tuto rialspo int.co m/java/java_basic_o perato rs.htm Copyrig ht tutorialspoint.com Java provides a rich set of operators to manipulate variables. We can divide all the
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 informationCT 229. Java Syntax 26/09/2006 CT229
CT 229 Java Syntax 26/09/2006 CT229 Lab Assignments Assignment Due Date: Oct 1 st Before submission make sure that the name of each.java file matches the name given in the assignment sheet!!!! Remember:
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 informationInformation Science 1
Information Science 1 Simple Calcula,ons Week 09 College of Information Science and Engineering Ritsumeikan University Topics covered l Terms and concepts from Week 8 l Simple calculations Documenting
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 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 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 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 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 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 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 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 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 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 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 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 informationCT 229 Java Syntax Continued
CT 229 Java Syntax Continued 29/09/2006 CT229 Lab Assignments One Week Extension for Lab Assignment 1. Due Date: Oct 8 th Before submission make sure that the name of each.java file matches the name given
More informationFundamentals of Programming CS110. Lecture 3
Fundamentals of Programming CS110 Lecture 3 Operators Operators Operators are words or symbols that cause a program to do something to variables. OPERATOR TYPES: Type Operators Usage Arithmetic +  *
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 informationbitwise inclusive OR Logical logical AND && logical OR Ternary ternary? : Assignment assignment = += = *= /= %= &= ^= = <<= >>= >>>=
Operators in java Operator in java is a symbol that is used to perform operations. For example: +, , *, / etc. There are many types of operators in java which are given below: Unary Operator, Arithmetic
More informationRUBY OPERATORS. Ruby Arithmetic Operators: Ruby Comparison Operators:
http://www.tutorialspoint.com/ruby/ruby_operators.htm RUBY OPERATORS Copyright tutorialspoint.com Ruby supports a rich set of operators, as you'd expect from a modern language. Most operators are actually
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 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 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 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 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 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 informationThe Java language has a wide variety of modifiers, including the following:
PART 5 5. Modifier Types The Java language has a wide variety of modifiers, including the following: Java Access Modifiers Non Access Modifiers 5.1 Access Control Modifiers Java provides a number of access
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 informationCOMP6700/2140 Operators, Expressions, Statements
COMP6700/2140 Operators, Expressions, Statements Alexei B Khorev and Josh Milthorpe Research School of Computer Science, ANU 3 March 2017 Alexei B Khorev and Josh Milthorpe (RSCS, ANU) COMP6700/2140 Operators,
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 informationJava Primer 1: Types, Classes and Operators
Java Primer 1 3/18/14 Presentation for use with the textbook Data Structures and Algorithms in Java, 6th edition, by M. T. Goodrich, R. Tamassia, and M. H. Goldwasser, Wiley, 2014 Java Primer 1: Types,
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 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 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 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 informationOperators And Expressions
Operators And Expressions Operators Arithmetic Operators Relational and Logical Operators Special Operators Arithmetic Operators Operator Action Subtraction, also unary minus + Addition * Multiplication
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 informationC++ 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 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 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 informationExpressions & Assignment Statements
Expressions & Assignment Statements 1 Topics Introduction Arithmetic Expressions Overloaded Operators Type Conversions Relational and Boolean Expressions ShortCircuit Evaluation Assignment Statements
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 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 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 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 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 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 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 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 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 informationC++ Basic Elements of COMPUTER PROGRAMMING. Special symbols include: Word symbols. Objectives. Programming. Symbols. Symbols.
EEE117 COMPUTER PROGRAMMING Basic Elements of C++ Objectives General Questions Become familiar with the basic components of a C++ program functions, special symbols, and identifiers Data types Arithmetic
More informationLecture 3 Tao Wang 1
Lecture 3 Tao Wang 1 Objectives In this chapter, you will learn about: Arithmetic operations Variables and declaration statements Program input using the cin object Common programming errors C++ for Engineers
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 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 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 informationBy the end of this section you should: Understand what the variables are and why they are used. Use C++ built in data types to create program
1 By the end of this section you should: Understand what the variables are and why they are used. Use C++ built in data types to create program variables. Apply C++ syntax rules to declare variables, initialize
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 informationExpressions and Statementst t. Assignment Operator. C Programming Lecture 6 : Operators. Expression
Expressions and Statementst t Expression C Programming Lecture 6 : Operators Combination of constants,variables,operators, operators and function calls a+b 3.0*x 9.66553 tan(angle) Statement An expression
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 informationA variable is a name that represents a value. For
DECLARE A VARIABLE A variable is a name that represents a value. For example, you could have the variable myage represent the value 29. Variables can be used to perform many types of calculations. Before
More informationChapter 4: Basic C Operators
Chapter 4: Basic C Operators In this chapter, you will learn about: Arithmetic operators Unary operators Binary operators Assignment operators Equalities and relational operators Logical operators Conditional
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 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 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 informationAdd Subtract Multiply Divide
ARITHMETIC OPERATORS if AND if/else AND while LOOP Order of Operation (Precedence Part 1) Copyright 2014 Dan McElroy Add Subtract Multiply Divide + Add  Subtract * Multiply / Divide = gives the quotient
More informationConstants and Variables
DATA STORAGE Constants and Variables In many introductory courses you will come across characteristics or elements such as rates, outputs, income, etc., measured by numerical values. Some of these will
More informationJAC444  Lecture 1. Introduction to Java Programming Language Segment 4. Jordan Anastasiade Java Programming Language Course
JAC444  Lecture 1 Introduction to Java Programming Language Segment 4 1 Overview of the Java Language In this segment you will be learning about: Numeric Operators in Java Type Conversion If, For, While,
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 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 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 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 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: Using Data
Chapter 2: Using Data TRUE/FALSE 1. A variable can hold more than one value at a time. F PTS: 1 REF: 52 2. The legal integer values are 2 31 through 2 311. These are the highest and lowest values that
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 informationLesson #3. Variables, Operators, and Expressions. 3. Variables, Operators and Expressions  Copyright Denis Hamelin  Ryerson University
Lesson #3 Variables, Operators, and Expressions Variables We already know the three main types of variables in C: int, char, and double. There is also the float type which is similar to double with only
More informationExpressions and Assignment Statements
Expressions and Assignment Statements Introduction Expressions are the fundamental means of specifying computations in a programming language To understand expression evaluation, need to be familiar with
More informationWeek 2: Console I/O and Operators Arithmetic Operators. Integer Division. Arithmetic Operators. Gaddis: Chapter 3 (2.14,3.16,3.910,5.
Week 2: Console I/O and Operators Gaddis: Chapter 3 (2.14,3.16,3.910,5.1) CS 1428 Fall 2014 Jill Seaman 1 2.14 Arithmetic Operators An operator is a symbol that tells the computer to perform specific
More informationAssoc. 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 multipleselection statement break statement continue statement Logical
More informationWEEK 4 OPERATORS, EXPRESSIONS AND STATEMENTS
WEEK 4 OPERATORS, EXPRESSIONS AND STATEMENTS OPERATORS Review: Data values can appear as literals or be stored in variables/constants Data values can be returned by method calls Operators: special symbols
More informationCP FAQS Q1) Define flowchart and explain Various symbols of flowchart Q2) Explain basic structure of c language Documentation section :
CP FAQS Q1) Define flowchart and explain Various symbols of flowchart ANS. Flowchart: A diagrametic reperesentation of program is known as flowchart Symbols Q2) Explain basic structure of c language
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 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 information