Chapter Two Operators and Expressions Lesson Seven.

Slides:



Advertisements
Similar presentations
Types and Arithmetic Operators
Advertisements

©2004 Brooks/Cole Chapter 2 Variables, Values and Operations.
Chapter 2: Java Fundamentals Operators. Introduction to OOP Dr. S. GANNOUNI & Dr. A. TOUIR Page 2 Content Group of Operators Arithmetic Operators Assignment.
1 Chapter 3 Arithmetic Expressions. 2 Chapter 3 Topics l Overview of Java Data Types l Numeric Data Types l Declarations for Numeric Expressions l Simple.
COMPSCI 125 Spring 2005 ©TheMcGraw-Hill Companies, Inc. Permission required for reproduction or display. Chapter 3: Numeric Data *Variables *Numeric data.
Aalborg Media Lab 21-Jun-15 Software Design Lecture 2 “ Data and Expressions”
ECE122 L3: Expression Evaluation February 6, 2007 ECE 122 Engineering Problem Solving with Java Lecture 3 Expression Evaluation and Program Interaction.
Chapter 3 Numerical Data. Topics Variables Numeric data types Assignment Expressions.
Fundamental Programming Structures in Java: Comments, Data Types, Variables, Assignments, Operators.
Primitive Types CSE 115 Spring 2006 April 3 &
1 Expressions, Operators Expressions Operators and Precedence Reading for this class: L&L, 2.4.
CSci 142 Data and Expressions. 2  Topics  Strings  Primitive data types  Using variables and constants  Expressions and operator precedence  Data.
1 Data types, operations, and expressions Continued l Overview l Assignment statement l Increment and Decrement operators l Short hand operators l The.
Performing Simple Calculations with C# Svetlin Nakov Telerik Corporation
Chapter 4: Operators Department of Computer Science Foundation Year Program Umm Alqura University, Makkah Computer Programming Skills /1436.
Java Primitives The Smallest Building Blocks of the Language (corresponds with Chapter 2)
Exercises A-Declare a variable of double type with initial value=0.0; B- Declare a constant of String type with initial value=“Good” C- Declare a variable.
2440: 211 Interactive Web Programming Expressions & Operators.
CHAPTER 2 PART #4 OPERATOR 2 nd semester King Saud University College of Applied studies and Community Service Csc 1101 By: Asma Alosaimi Edited.
Introduction to Java Applications Part II. In this chapter you will learn:  Different data types( Primitive data types).  How to declare variables?
CH2 – Using Data. Constant Something which cannot be changed Data Type Format and size of a data item Intrinsic Data Types Pg. 47 – Table 2-1 Basic ones.
Chapter 2: Using Data.
Operators in Python. Arithmetic operators Some operators in Python will look familiar (+, -, *, /) Others are new to you (%, //, **) All of these do work.
Assignment Statements Operator Precedence. ICS111-Java Programming Blanca Polo 2 Assignment, not Equals  An assignment statement changes the value of.
BUILDING JAVA PROGRAMS CHAPTER 2 PRIMITIVE DATA TYPES AND OPERATIONS.
CHAPTER 4: CONTROL STRUCTURES - SEQUENCING 10/14/2014 PROBLEM SOLVING & ALGORITHM (DCT 1123)
Mathematical Calculations in Java Mrs. G. Chapman.
Building Java Programs Primitive Data and Definite Loops.
Operators Precedence - Operators with the highest precedence will be executed first. Page 54 of the book and Appendix B list C's operator precedence. Parenthesis.
Boolean Logic Logical Operators Comparison Operators Truth tables.
Mathematical Calculations in Java Mrs. C. Furman.
COM S 207 Literal, Operator, and Expression Instructor: Ying Cai Department of Computer Science Iowa State University
Programming in Java (COP 2250) Lecture 4 Chengyong Yang Fall, 2005.
Arithmetic OperatorOperationExample +additionx + y -subtractionx - y *multiplicationx * y /divisionx / y Mathematical FormulaC Expressions b 2 – 4acb *
This will all add up in the end. Assignment operator =Simple Assignment operator Arithmetic Operators +Additive operator – Subtraction operator * Multiplication.
Arithmetic Expressions Addition (+) Subtraction (-) Multiplication (*) Division (/) –Integer –Real Number Mod Operator (%) Same as regular Depends on the.
Performing Simple Calculations with C# Telerik Corporation
Doing math In java.
Introduction to Java Applications Part II. In this chapter you will learn:  Different data types( Primitive data types).  How to declare variables?
© 2007 Pearson Addison-Wesley. All rights reserved2-1 Character Strings A string of characters can be represented as a string literal by putting double.
What are Operators? Some useful operators to get you started.
Operators and Expressions
CSCI 1100/1202 January 18, Arithmetic Expressions An expression is a combination of operators and operands Arithmetic expressions compute numeric.
Chapter 2: Data and Expressions. Variable Declaration In Java when you declare a variable, you must also declare the type of information it will hold.
What will each of the following lines print? System.out.println("number" ); number645 System.out.println("number" + (6 + 4)+ 5); number105 System.out.println(6.
Chapter 3 Math Operations. Objectives Use the assignment and arithmetic operators. Use operators in output statements. Explain the problem with division.
CompSci 230 S Programming Techniques
Chapter 7: Expressions and Assignment Statements
2.0 FUNDAMENTALS OF JAVA PROGRAMMING LANGUAGE
Operators Operators are symbols such as + (addition), - (subtraction), and * (multiplication). Operators do something with values. $foo = 25; $foo – 15;
Chapter 7: Expressions and Assignment Statements
Expressions An expression is a portion of a C++ statement that performs an evaluation of some kind Generally requires that a computation or data manipulation.
Nahla Abuel-ola / WIT.
Type Conversion, Constants, and the String Object
Arithmetic Operator Operation Example + addition x + y
Examples of Primitive Values
With Assignment Operator
Arithmetic Expressions
More Maths Programming Guides.
Chapter 2: Java Fundamentals
Chapter 3 Operators and Expressions
Fundamental OOP Programming Structures in Java: Comments, Data Types, Variables, Assignments, Operators.
Operators In Java Programming By Rajanikanth B.
Chapter 4: Expression and Operator
In this class, we will cover:
Operator King Saud University
Algoritma & Pemrograman 1
Data Types and Expressions
Primitive Data Types and Operators
Building Java Programs
Presentation transcript:

Chapter Two Operators and Expressions Lesson Seven

What is Operator Operators allow processing of primitive data types and objects. They take as an input one or more operands and return some value as a result.

Operators in C# can be separated in several different categories: -Arithmetic operators – they are used to perform simple mathematical operations. - Assignment operators – allow assigning values to variables. - Comparison operators – allow comparison of two literals and/or variables. - Logical operators – operators that work with Boolean data types and Boolean expressions.

Category and Operators CategoryOperators arithmetic-, +, *, /, %, ++, -- logical&&, ||, !, ^ comparison==,!=, >, =, <= assignment=, +=, -=, *=, /=, %=, &=, |=, ^=, >= string concatenation+

Arithmetical Operators The arithmetical operators in C# +, -, * are the same like the ones in math. They perform addition, subtraction and multiplication on numerical values and the result is also a numerical value.

Division is Different The division operator / has different effect on integer and real numbers. When we divide an integer by an integer (like int,) the returned value is an integer (no rounding, the fractional part is cut). Such division is called an integer division. Example of integer division: 7 / 3 = 2.

Remainder of Devision The remainder of integer division of integers can be obtained by the operator %. For example, 7 % 3 = 1, and –10 % 2 = 0.

Dividing A real Number When dividing two real numbers or two numbers, one of which is real (e.g. float, double, etc.), a real division is done (not integer), and the result is a real number with a whole and a fractional part. For example: 5.0 / 2 = 2.5.

increment decrement(++ and --) The operator for increasing by one (increment) ++ adds one unit to the value of the variable, respectively the operator -- (decrement) subtracts one unit from the value.

Example { int squarePerimeter = 19; double squareSide = squarePerimeter / 6.0; double squareArea = squareSide * squareSide; Console.WriteLine(squareSide); Console.WriteLine(squareArea); int a = 5; int b = 10; Console.WriteLine(a + b); Console.WriteLine(a + (++b)); Console.WriteLine(a + b); Console.WriteLine(14 / a); Console.WriteLine(14 % a); Console.ReadKey(); }

Exercise 1)Qor program ka shaqeynayo areada trapezium adigoo weydinayo in uu userka soo galiyo qiima a, b iyo h Note: hadii maada xisaabta mar hore kugu dambeesay trapezium areadiisa waxaa lagu helaa xusuusnow xisaabtu muhiim ayee u tahay programming

NEXT LESSON Logical Operators