Operators. The Basics + (addition) - (subtraction) * (multiplication) / (division) % (modulo) ( ) (parentheses)

Slides:



Advertisements
Similar presentations
INTEC CS160 - Jeanine Ingber Engineering Problem Solving with C Fundamental Concepts Chapter 3 Control Structures and Data Files.
Advertisements

AP Computer Science Anthony Keen. Computer 101 What happens when you turn a computer on? –BIOS tries to start a system loader –A system loader tries to.
Department of Computer Science. Definition “An operator is a symbol (+,-,*,/) that directs the computer to perform certain mathematical or logical manipulations.
Air Force Institute of Technology Electrical and Computer Engineering
Operators and Expressions Rohit Khokher. Operators and Expression OperatorsSymbols Arithmetic+ - * / % Relational >= == != Logical&& || ! Assignment=
IntroductionIntroduction  Computer program: an ordered sequence of statements whose objective is to accomplish a task.  Programming: process of planning.
1 Engineering Problem Solving With C++ An Object Based Approach Chapter 3 Control Structures.
All the Operators. Precedence An operator with higher precedence is done earlier (prededes) one with lower precedence –A higher precedence is indicated.
All the Operators. Precedence An operator with higher precedence is done earlier (prededes) one with lower precedence –A higher precedence is indicated.
Lecture 02 Data Types, Conversions if Statements METU Dept. of Computer Eng. Summer 2002 Ceng230 - Section 01 Introduction To C Programming by Ahmet Sacan.
CS 3850 Lecture 5 Operators. 5.1 Binary Arithmetic Operators Binary arithmetic operators operate on two operands. Register and net (wire) operands are.
1 Bitwise Operators. 2 Bitwise Operators (integers) Bitwise "and" operator & Bitwise "or" operator | Bitwise "exclusive or" operator ^ Bitwise "ones complement"
2015/8/221 Data Types & Operators Lecture from (Chapter 3,4)
IDK0040 Võrgurakendused I harjutus 07: PHP: Operators, Switch, Forms Deniss Kumlander.
4. Python - Basic Operators
Intro to C++ for Robotics Made for ALARM. Computer System Hardware – cpu, memory, i/o Software – OS, drivers.
CMPE-013/L: “C” Programming Gabriel Hugh Elkaim – Spring 2013 CMPE-013/L Operators Gabriel Hugh Elkaim Spring 2012.
OperatorstMyn1 Operators The sequence in which different operators in an expression are executed is determined by the precedence of the operators. Operators.
 Input and Output Functions Input and Output Functions  OperatorsOperators Arithmetic Operators Assignment Operators Relational Operators Logical Operators.
Simple Data Types and Statements. Namespaces namespace MyNamespace { // …. { MyNamespace::func1() using namespace OtherNamespace; Comments: // /* xxxx.
Basic Operators. What is an operator? using expression is equal to 9. Here, 4 and 5 are called operands and + is the operator Python language supports.
Sudeshna Sarkar, IIT Kharagpur 1 Programming and Data Structure Sudeshna Sarkar Lecture 5.
C++ Basics Tutorial 6 Operators. What are going to see today? Assignment operator(=) Arithmetic operators(+,-,*,/,%) Compound assignment(+=,-=,*=……..)
Dennis Ritchie 1972 AT & T Bell laboratories (American Telephone and Telegraph) USA 1www.gowreeswar.com.
CSIS 113A Lecture 3 Conditional & Switch Glenn Stevenson CSIS 113A MSJC.
Increment Operator To increment a variable X by 1. X+1;X+=;++X; X = 10 Y = X + 1;Y = 11 X += 1;X = 11 Y = ++X + 4;Y = 15.
C Programming Lecture 7 : Control Structures. Control Structures Conditional statement : if, switch Determine a block of statements to execute depending.
15-Nov-15 All the Operators. operators.ppt 2 Precedence An operator with higher precedence is done earlier (precedes) one with lower precedence A higher.
Lesson - 5. Introduction While programming, we usually need to decide the path of the program flow according to the parameters and conditions. Actually.
Week 8: Decisions Bryan Burlingame 21 October 2015.
Assignment statement: Assigns a value to a variable Variable must appear on the left side, value on the right side of the assignment operator Right side.
Chapter 15 JavaScript: Part III The Web Warrior Guide to Web Design Technologies.
Centre for Computer Technology ICT214 Object Oriented Design and Programming Week 03 – Operators, Algorithm Design, Programming Constructs Richard Salomon.
Expressions and Operators in C. Expressions and Operators Examples: 3 + 5; x; x=0; x=x+1; printf("%d",x); Two types: – Function calls – The expressions.
Operators & Expressions
Python Mini-Course University of Oklahoma Department of Psychology Day 3 – Lesson 10 Iteration: Loops 05/02/09 Python Mini-Course: Day 3 - Lesson 10 1.
Expressions and Control Flow. Expressions An expression is a combination of values, variables, operators, and functions that results in a value y = 3(abs(2x)
2: Basics Basics Programming C# © 2003 DevelopMentor, Inc. 12/1/2003.
ECE 103 Engineering Programming Chapter 4 Operators Herbert G. Mayer, PSU CS Status 6/19/2015 Initial content copied verbatim from ECE 103 material developed.
Expression and Operator. Expressions and Operators u Examples: 3 + 5; x; x=0; x=x+1; printf("%d",x); u Two types: –Function calls –The expressions formed.
Java Basics. Tokens: 1.Keywords int test12 = 10, i; int TEst12 = 20; Int keyword is used to declare integer variables All Key words are lower case java.
Chad’s C++ Tutorial Demo Outline. 1. What is C++? C++ is an object-oriented programming (OOP) language that is viewed by many as the best language for.
Dr. Sajib Datta Jan 23,  A precedence for each operator ◦ Multiplication and division have a higher precedence than addition and subtraction.
CS 161 Introduction to Programming and Problem Solving Chapter 12 C++ Statements Herbert G. Mayer, PSU Status 10/8/2014 Initial content copied verbatim.
CMPE-013/L: “C” Programming Gabriel Hugh Elkaim – Spring 2012 CMPE-013/L Operators Gabriel Hugh Elkaim Spring 2012.
Lecture 3.1 Operators and Expressions Structured Programming Instructor: Prof. K. T. Tsang 1.
Operator Kinds of Operator Precedence of Operator Type Casting.
LESSON 3 Expressions, Statements, & Operators. STATEMENTS A statement Controls the sequence of execution Evaluates an expression Does nothing (the null.
Dr. Sajib Datta Sep 3,  A new operator used in C is modulus operator: %  % only used for integers, not floating-point  Gives the integer.
Department of Software.
ECE 103 Engineering Programming Chapter 4 Operators Herbert G. Mayer, PSU Status 6/10/2016 Initial content copied verbatim from ECE 103 material developed.
Operators & Expressions
Operators And Expressions
University of Central Florida COP 3330 Object Oriented Programming
Sequence, Selection, Iteration The IF Statement
Unit-1 Introduction to Java
University of Central Florida COP 3330 Object Oriented Programming
Precedence and Associativity
Expressions and Control Flow in JavaScript
Java operatoriai
Introduction to C Programming
Operators and Expressions
Lecture 5 from (Chapter 4, pages 73 to 96)
Character Set The character set of C represents alphabet, digit or any symbol used to represent information. Types Character Set Uppercase Alphabets A,
All the Operators 22-Nov-18.
Introduction to C Programming
Introduction to Programming – 4 Operators
Herbert G. Mayer, PSU CS Status 7/19/2015
OPERATORS in C Programming
OPERATORS in C Programming
Presentation transcript:

Operators

The Basics + (addition) - (subtraction) * (multiplication) / (division) % (modulo) ( ) (parentheses)

Bitwise operations << (shift left) >> (shift right) | (bitwise or) & (bitwise and) ^ (bitwise exclusive or) ~ (one’s complement)

Logical operations || (logical or), && (logical and) ! (logical not) != (not equal), == (equal) (greater than) = (greater than/equal) 0 == false, anything else == true

And a few more... ? : (a three way arithmetic if) & (address of), * (dereference) ++ (increment), -- (decrement) -> (dereference),. (member) sizeof() [ ] (array subscript)

Order of Precedence ( ) (function call) [ ] (subscripts) -> and. (dereference) sizeof ! ~ ,-- &, * (address,deref) *, /, % +, - >,>= ==,!= & | &&, ||, =

Control statements

if if (x == 5) x=4; if (x==5) x=0; else x=1; if (x>=5 && x<=10) printf(“Bingo!\n”);

for for (i=0;i<10;i++) printf(“%d\n”,i); for(i=0;i<10;i=i+2) for(;;)

while while (x != 0) x=x-1;

do...while do x=x+1 while (x < 100);

More control statements

switch char key; scanf(“&c”,&key); switch (key) { case ‘a’: printf(“a is for aardvark\n”); case ‘b’: printf(“b is for beer\n”);break; case ‘c’: printf(“c is for cow\n”);break; default: printf(“Just my ABC’s\n”); }

break Necessary for switch statements Can be used in while and for statements “break” out of a loop

continue Similar to break but keeps within the loop

Printing to the printer The ‘lp’ command lp -d student myprog.c DON’T print a.out lpstat -p cancel student