SlideShare a Scribd company logo
C Programming - Operators and Expressions 2 Copyright © 2010 Dorling Kindersley (India) Pvt. Ltd.
Programming in C: A Practical Approach Operators and Expressions Expressions An  expression  in C is made up of one or more operands. The simplest form of an expression consists of a single operand. For example, 3 is an expression that consists of a single operand i.e. 3. Such an expression does not specify any operation to be performed and is not meaningful.  For example,  a=2+3  // meaningful expression Involves three operands :a, 2 and 3 Two operators i.e. = (assignment operator) and + (arithmetic addition operator).  Thus, an expression is a sequence of operands and operators that specifies the computation of a value. Copyright © 2010 Dorling Kindersley (India) Pvt. Ltd.
Programming in C: A Practical Approach Operators and Expressions Operands An  operand  specifies an entity on which an operation is to be performed.  An operand can be a variable name, a constant.  For example, a=b+2 is a valid expression involving three operands namely,  a variable name i.e. a, a variable name i.e. b,  a constant i.e. 2. Copyright © 2010 Dorling Kindersley (India) Pvt. Ltd.
Programming in C: A Practical Approach Operators and Expressions Operators An  operator  specifies the operation to be applied to its operands.  For example, the expression: a=b+2; involves two operators namely, arithmetic addition operator i.e. + assignment operator i.e. =.   Based on the number of operators present in an expression, expressions are classified as simple expressions and compound expressions. Copyright © 2010 Dorling Kindersley (India) Pvt. Ltd.
Simple and Compound Expressions Programming in C: A Practical Approach Operators and Expressions Simple Expressions An expression that has only one operator is known as  simple expression . E.g., a+2 is a simple expression. Evaluation of simple expression is easier as order of determination is trivial in this case as there is only one operator. Compound Expressions An expression that involves more than one operator is called  compound expression. E.g. b=2+3*5 is a compound expression. Whereas the evaluation of a compound expression requires the correct order in which the operators will operate. This depends upon the  Precedence  and the  Associativity  of operators.  Copyright © 2010 Dorling Kindersley (India) Pvt. Ltd.
Precedence of Operators Each operator in C has a  precedence  associated with it. In a compound expression, if the operators involved are of different precedence, the operator of higher precedence is evaluated first. For example, in an expression b=2+3*5,  The sub-expression 3*5 involving multiplication operator  (i.e. *). The result of evaluation of an expression is an r-value. The sub-expression 3*5 evaluates to an r-value 15. This r-value will act as second operand for addition operator and the expression becomes b=2+15. Programming in C: A Practical Approach Operators and Expressions Copyright © 2010 Dorling Kindersley (India) Pvt. Ltd.
Programming in C: A Practical Approach Operators and Expressions In the resultant expression, the sub-expression 2+15. The expression after the evaluation of the addition operator reduces to b=17.  Now, there is only one operator in the expression. The assignment operator will operate and the value 17 is assigned to b.  The precedence order is * > + > =. The knowledge of precedence of operators alone is not sufficient to evaluate a compound expression in case two or more operators involved are of same precedence. To determine which of these operators will operate first, the  Associativity  of these operators is to be considered. Copyright © 2010 Dorling Kindersley (India) Pvt. Ltd.
Programming in C: A Practical Approach Operators and Expressions Associativity of Operators Key Points An operator can be either left-to-right associative or right-to-left associative.  The operators with same precedence always have the same associativity.  If operators are left-to-right associative, they are applied in left-to-right order i.e. the operator which appears towards left will be evaluated first. If they are right-to-left associative, they will be applied in the right-to-left order.  The multiplication and the division operators are left-to-right associative. Hence, in expression 2*3/5, the multiplication operator is evaluated prior to the division operator as it appears before the division operator in left-to-right order. Copyright © 2010 Dorling Kindersley (India) Pvt. Ltd.
Classification of Operators Programming in C: A Practical Approach Operators and Expressions Copyright © 2010 Dorling Kindersley (India) Pvt. Ltd.   TERNARY OPERATOR BINARY OPERATOR UNARY OPERATOR BASED ON NO. OF OPERATORS BASED ON ROLE OF OPERATOR BITWISE OPERATORS MISCELLANEOUS OPERATORS ARITHMETIC OPERATORS ASSIGNMENT OPERATORS LOGICAL OPERATORS RELATIONAL OPERATORS CLASSIFICATION OF OPERATORS
Based on No. of Operators Unary Operators Unary  operator operates on only one operand.  For example, in the expression -3, - is unary minus operator as it operates on only one operand i.e. 3. The operand can be present towards the right of unary operator, as in -3 or towards the left of unary operator, as in the expression a++.  Examples of unary operators are: & (address-of operator) sizeof operator ! (logical negation) ~ (bitwise negation) ++ (increment operator) -- (decrement operator) etc. Programming in C: A Practical Approach Operators and Expressions Copyright © 2010 Dorling Kindersley (India) Pvt. Ltd.
Binary Operators Binary operator operates on two operands. It requires an operand towards its left and right.  For example, in expression 2-3 - is acting as binary minus operator as it is operating on two operands i.e. 2 and 3.  Examples of binary operators are:  * (multiplication operator), / (division operator), << (left shift operator), == (equality operator), && (logical AND), & (bitwise AND) etc. Programming in C: A Practical Approach Operators and Expressions Copyright © 2010 Dorling Kindersley (India) Pvt. Ltd.
Ternary Operators Ternary operator operates on three operands.  Conditional operator (i.e. ? :) is the only ternary operator available in C.  Programming in C: A Practical Approach Operators and Expressions Copyright © 2010 Dorling Kindersley (India) Pvt. Ltd.
Based on Role Of Operator Arithmetic Operators The arithmetic operations like addition, subtraction, multiplication, division etc. can be performed by using arithmetic operators. Following arithmetic operators are available in C: Programming in C: A Practical Approach Operators and Expressions Copyright © 2010 Dorling Kindersley (India) Pvt. Ltd.   The operators within a row have the same precedence and the order in which they are written does not matter.  S.No Operator Name of Operator Category -ary of Operators Precedence amongst arithmetic class Associativity 1. + -  ++ -- Unary plus Unary minus Increment  Decrement Unary operators Unary Level-I  (Highest) R->L  (Right-to-left) 2. * / % Multiplication Division Modulus Multiplicative operators Binary Level-II  (Intermediate) L->R (Left-to-right) 3. + - Addition Subtraction Additive operators Binary Level-III (Lowest) L->R
Key Points: Arithmetic Operators The parenthesized sub-expressions are evaluated first. If the parentheses are nested, the innermost sub-expression is evaluated first. The precedence rules are applied to determine the order of application of operators while evaluating sub-expressions. The associativity rule is applied when two or more operators of the same precedence appear in the sub-expression. If the operands of a binary arithmetic operator are of different but compatible types, C automatically applies  arithmetic type conversion  to bring the operands to a common type. This automatic type conversion is known as  implicit type conversion . The result  Programming in C: A Practical Approach Operators and Expressions Copyright © 2010 Dorling Kindersley (India) Pvt. Ltd.
of evaluation of operator will be of  common type . The basic principle behind the implicit arithmetic type conversion is that if operands are of different types, the lower type (i.e. smaller in size) should be converted to a higher type (i.e. bigger in size) so that there is no loss in value or precision. Since, a lower type is converted to a higher type, it is said that lower type is  promoted  to a higher type and the conversion is known as  promotion . Programming in C: A Practical Approach Operators and Expressions Copyright © 2010 Dorling Kindersley (India) Pvt. Ltd.
Arithmetic Type Conversions If one operand is long double, the other will be converted to long double and the result will be long double.  If one operand is double, the other will be converted to double and the result will be double. If one operand is float, the other will be converted to float and the result will be float.  If one of the operands is unsigned long int, the other will be converted to unsigned long int and the result will be unsigned long int.  Programming in C: A Practical Approach Operators and Expressions Copyright © 2010 Dorling Kindersley (India) Pvt. Ltd.
If one operand is long int and other is unsigned int then  If unsigned int can be converted to long int, then unsigned int operand will be converted as such and the result will be long int.  Else, both operands will be converted to unsigned long int and the result will be unsigned long int.  If one of the operands is long int, the other will be converted to long int and the result will be long int. If one operand is unsigned int, the other will be converted to unsigned int and the result will be unsigned int. If none of the above is carried out, both the operands are converted to int. Programming in C: A Practical Approach Operators and Expressions Copyright © 2010 Dorling Kindersley (India) Pvt. Ltd.
Key Points: Arithmetic Operators 1. The  unary plus operator  can appear only towards the left side of its operand. 2. The  unary minus operator  can appear only towards the left side of its operand. 3. Increment operator The increment operator can appear towards the left side or  towards the right side of its operand. If it appears towards the left  side of its operand (e.g. ++a), it is known as  pre-increment operator . If it appears towards the right side of its operand (e.g. a++), it is known as  post-increment operator . The increment operator can only be applied to an operand that has a modifiable L-value. If it is applied to an operand that does not have a modifiable L-value, there will be “L-value required” error. Programming in C: A Practical Approach Operators and Expressions Copyright © 2010 Dorling Kindersley (India) Pvt. Ltd.
++a or a++ is equivalent to a=a+1. The  difference between pre-increment and post-increment  lies in the point at which the value of their operand is incremented.  In case of pre-increment operator, first the value of its operand is incremented and then it is used for the evaluation of expression.  In case of post-increment operator, the value of operand is used first for the evaluation of the expression and after its use, the value of the operand is incremented.  Increment operator is a token i.e. one unit. There should be no white space character between two ‘+’ symbols. If white space is placed between two ‘+’ symbols, they become two unary plus (+) operators. Programming in C: A Practical Approach Operators and Expressions Copyright © 2010 Dorling Kindersley (India) Pvt. Ltd.
Programming in C: A Practical Approach Operators and Expressions Tokens  are the basic building blocks of a source code. Characters are combined into tokens according to the rules of the programming language. There are five classes of tokens: identifiers, reserved words, operators, separators and constants.  Copyright © 2010 Dorling Kindersley (India) Pvt. Ltd.   4. Decrement operator The decrement operator can appear towards the left side or towards the right side of its operand. If it appears towards the left side of its operand (e.g. --a), it is known as  pre-decrement operator . If it appears towards the right side of its operand (e.g. a--), it is known as  post-decrement operator. The decrement operator can only be applied to an operand that has a modifiable L-value. If it is applied on an operand that does not have a modifiable L-value, there will be a compilation error “L-value required”.
--a or a-- is equivalent to a=a-1. The  difference between pre-decrement and post-decrement  lies in the point at which the value of their operand is decremented.  In case of pre-decrement operator, firstly the value of its operand is decremented and then used for the evaluation of the expression in which it appears.  In case of post-decrement operator, firstly the value of operand is used for the evaluation of the expression in which it appears and then, its value is decremented. Decrement operator is a token i.e. one unit. There should be no white space character between two ‘-’ symbols. If white space is placed between two ‘-’ symbols, they become two unary minus (-) operators. Programming in C: A Practical Approach Operators and Expressions Copyright © 2010 Dorling Kindersley (India) Pvt. Ltd.
5. Division operator The division operator is used to find the quotient. The sign of the result of evaluation of division operator depends upon the sign of both numerator as well as denominator. If both are positive, the result will be positive. If both are negative, the result will be positive. If either of the two is negative, the result will be negative. For example: 4/3=1, -4/3=-1, 4/-3=-1 and -4/-3=1.  6. Modulus operator The modulus operator is used to find the remainder. The operands of modulus operator (i.e. %) must be of integer type. Modulus operator cannot have operands of floating point type.  The sign of the result of evaluation of modulus operator depends only upon the sign of numerator. If sign of numerator is positive, the sign of result will be positive else negative. For example: 4%3=1, -4%3=-1, 4%-3=1 and -4%-3=-1.  Programming in C: A Practical Approach Operators and Expressions Copyright © 2010 Dorling Kindersley (India) Pvt. Ltd.
Relational Operators Relational operators are used to compare two quantities (i.e. their operands). There are six relational operators in C: Programming in C: A Practical Approach Operators and Expressions Copyright © 2010 Dorling Kindersley (India) Pvt. Ltd.   S.No Operator Name of Operator Category -ary of Operators Precedence amongst  relational class Associativity 1. < >  <= >= Less than Greater than Less than or equal to Greater than or equal to Relational operators Binary Level-I  L->R 2. == != Equal to Not equal to Equality operators Binary Level-II  L->R
Key Points: Relational Operators There should be no white space character between two symbols of a relational operator. The result of evaluation of a relational expression (i.e. involving relational operator) is a boolean constant i.e. 0 or 1. Each of the relational operators yields 1 if the specified relation is true and 0 if it is false. The result has type int. The expression a<b<c is valid and is not interpreted as in ordinary mathematics. Since, less than operator (i.e. <) is left-to-right associative, the expression is interpreted as (a<b)<c. This means that “if a is less than b, compare 1 with c, otherwise, compare 0 with c”. An expression that involves a relational operator forms a  condition . For example, a<b is a condition. Programming in C: A Practical Approach Operators and Expressions Copyright © 2010 Dorling Kindersley (India) Pvt. Ltd.
Logical Operators Logical operators are used to logically relate the expressions. The C language has the following logical operators:  In C language, there is no operator available for logical  eXclusive-OR (XOR) operation.  Programming in C: A Practical Approach Operators and Expressions Copyright © 2010 Dorling Kindersley (India) Pvt. Ltd.   S.No Operator Name of Operator Category -ary of Operators Precedence amongst  logical class Associativity 1. ! Logical NOT Unary Unary Level-I  R->L  2. && Logical AND Logical operator Binary Level-II  L->R 3. || Logical OR Logical operator Binary Level-III L->R
Key Points: Logical Operators Logical operators consider operand as an entity, a unit. Logical operators operate according to the following truth tables: Programming in C: A Practical Approach Operators and Expressions Copyright © 2010 Dorling Kindersley (India) Pvt. Ltd.   OPERAND 1 OPERAND 2 AND OPERATION OR OPERATION FALSE FALSE FALSE FALSE FALSE TRUE FALSE TRUE TRUE FALSE FALSE TRUE TRUE TRUE TRUE TRUE OPERAND NOT OPERATION FALSE TRUE TRUE FALSE
If an operand of a logical operator is a non-zero value, the operand is considered as true. If operand is zero, it is considered as false.  Each of the logical operators yields 1 if the specified relation evaluates to true and 0 if it evaluates to false. The evaluation is done according to the truth tables mentioned in previous slide. The result has type int. The logical AND (i.e. &&) operator and the logical OR (i.e. ||) operator guarantee left to right evaluation. Expressions connected by && or || are evaluated left to right and the evaluation stops as soon as truthfulness or falsehood of the result is Programming in C: A Practical Approach Operators and Expressions Copyright © 2010 Dorling Kindersley (India) Pvt. Ltd.
known. Thus, in an expression: E1&&E2, where E1 and E2 are sub-expressions, E1 is evaluated first. If E1 evaluates to 0 (i.e. false), E2 will not be evaluated and the result of overall expression will be 0 (i.e. false). If E1 evaluates to a non-zero value (i.e. true) then E2 will be evaluated to determine the truth value of overall expression. E1||E2, where E1 and E2 are sub-expressions, E1 is evaluated first. If E1 evaluates to a non-zero value (i.e. true), E2 will not be evaluated and the result of overall expression will be 1 (i.e. true). If E1 evaluates to 0 (i.e. false) then E2 will be evaluated to determine the truth value of overall expression. Programming in C: A Practical Approach Operators and Expressions Copyright © 2010 Dorling Kindersley (India) Pvt. Ltd.
Bitwise Operators The C language provides six operators for bit manipulation. These operators do not consider operand as one entity and operate on the individual bits of operands. The following bitwise operators are available in C: Programming in C: A Practical Approach Operators and Expressions Copyright © 2010 Dorling Kindersley (India) Pvt. Ltd.   S.No Operator Name of Operator Category -ary of Operators Precedence amongst  bitwise class Associativity 1. ~ Bitwise NOT Unary Unary Level-I  R->L  2. << >> Left Shift Right Shift Shift operators Binary Level-II  L->R 3. & Bitwise AND Bitwise operator Binary Level-III L->R 4. ^ Bitwise X-OR Bitwise operator Binary Level-IV L->R 5. | Bitwise OR Bitwise operator Binary Level-V L->R
Assignment Operators A variable can be assigned a value by using assignment operator.  The following assignment operators are available in C language: Programming in C: A Practical Approach Operators and Expressions Copyright © 2010 Dorling Kindersley (India) Pvt. Ltd.   S. No Operator Name of Operator Category -ary of Operators Precedence  Associativity 1. = *= /= %= += -= &= |= ^= <<= >>= Simple assignment Assign product Assign quotient Assign modulus Assign sum Assign difference Assign bitwise AND Assign bitwise OR Assign bitwise XOR Assign left shift Assign right shift Assignment Shorthand assignment operators Binary Level-I  R->L
Key Points: Assignment Operators The operand that appears towards the left side of an assignment operator should have a modifiable l-value. If the operand appearing towards the left side of the assignment operator does not have modifiable l-value, there will be a compilation error “L-value required”.  The shorthand assignment is of the form op1 op=op2, where op1 and op2 are operands and op= is a shorthand assignment operator. It is a shorter way of writing op1 = op1 op op2. For example, a/=2 is equivalent to a=a/2.  There should be no white space character between two symbols of short-hand assignment operators. If two operands of an assignment operator are of different types, the type of operand on the right side of assignment operator is Programming in C: A Practical Approach Operators and Expressions Copyright © 2010 Dorling Kindersley (India) Pvt. Ltd.
automatically converted to the type of operand present on its left side. To carry out this conversion, either promotion or demotion is applied. The terms assignment and initialization are related but it is important to note the differences between them: Programming in C: A Practical Approach Operators and Expressions Copyright © 2010 Dorling Kindersley (India) Pvt. Ltd.   S.No Initialization Assignment 1. First time assignment at the time of definition is called initialization.  For example:  int a=10; is initialization of  a . Value of a data object after initialization can be changed by the means of assignment.  For example: Consider the following statements int a=10; a=20;  The value of  a  is changed to 20 by the assignment statement. 2. Initialization can be done only once. Assignment can be done any number of times. 3. Qualified constant can be initialized with a value.  For example, const int a=10; is valid. Qualified constant cannot be assigned a value. It is erroneous to write a=10; if  a  is a qualified constant.
Miscellaneous Operators Other operators available in C are: Function call operator (i.e. ()) Array subscript operator (i.e. []) Member select operator  Direct member access operator (i.e. . (dot operator or period)) Indirect member access operator (i.e. -> (arrow operator)) Indirection operator (i.e. *) Conditional operator Comma operator sizeof operator Address-of operator (i.e. &) Programming in C: A Practical Approach Operators and Expressions Copyright © 2010 Dorling Kindersley (India) Pvt. Ltd.
Sizeof Operator The sizeof operator is used to determine the size in bytes that a value or a data object will take in memory. The following are the important points about sizeof operator: The general form of sizeof operator is: sizeof expression  or  sizeof (expression)   (For example: sizeof 2, sizeof(a), sizeof(2+3)) sizeof (type-name)  (For example: sizeof(int), sizeof(int*), sizeof(char)) Programming in C: A Practical Approach Operators and Expressions Copyright © 2010 Dorling Kindersley (India) Pvt. Ltd.   S.No Operator Name of Operator Category ary of Operators Precedence  Associativity 1. sizeof Size-of operator Unary Unary Level-I R->L
Parentheses are must if sizeof operator is applied on a type-name, as indicated in the point 1 b) above. The type of result of evaluation of sizeof operator is int. The operand of sizeof operator is not evaluated.  The sizeof operator cannot be applied on operands of incomplete type or function type. Programming in C: A Practical Approach Operators and Expressions Copyright © 2010 Dorling Kindersley (India) Pvt. Ltd.
Combined Precedence of All Operators Till now we have discussed  intra-class precedence,  now we will discuss the  inter-class precedence Programming in C: A Practical Approach Operators and Expressions Copyright © 2010 Dorling Kindersley (India) Pvt. Ltd.   S.No Operator Name of Operator Category -ary of Operators Precedence  Associativity 1. () [] -> . Function call Array subscript Indirect member access Direct member access Level-I (Highest) 2. ! ~ + - ++ -- & * sizeof Logical NOT Bitwise NOT Unary plus Unary minus Increment Decrement Address-of Deference Sizeof Unary Unary Level-II R->L 3. * / % Multiplication Division Modulus Multiplicative operators Binary Level-III  L->R
Programming in C: A Practical Approach Operators and Expressions Copyright © 2010 Dorling Kindersley (India) Pvt. Ltd.   S.No Operator Name of Operator Category ary of Operators Precedence  Associativity 4. + - Addition Subtraction Additive operators Binary Level-IV L->R 5. << >> Left Shift Right Shift Shift operators Binary Level-V L->R 6. < >  <= >= Less than Greater than Less than or equal to Greater than or equal to Relational operators Binary Level-VI  L->R 7. == != Equal to Not equal to Equality operators Binary Level-VII  L->R 8. & Bitwise AND Bitwise operator Binary Level-VIII L->R 9. ^ Bitwise X-OR Bitwise operator Binary Level-IX L->R 10. | Bitwise OR Bitwise operator Binary Level-X L->R 11. && Logical AND Logical operator Binary Level-XI  L->R 12. || Logical OR Logical operator Binary Level-XII L->R 13. ?: Conditional operator Conditional Ternary Level-XIII  R->L
Programming in C: A Practical Approach Operators and Expressions Copyright © 2010 Dorling Kindersley (India) Pvt. Ltd.   S.No Operator Name of Operator Category ary of Operators Precedence  Associativity 14. = *= /= %= += -= &= |= ^= <<= >>= Simple assignment Assign product Assign quotient Assign modulus Assign sum Assign difference Assign bitwise AND Assign bitwise OR Assign bitwise XOR Assign left shift Assign right shift Assignment & Shorthand assignment operators Binary Level-XIV  R->L  15. , Comma operator Comma Binary Level-XV (Least) L->R

More Related Content

What's hot

Expression and Operartor In C Programming
Expression and Operartor In C Programming Expression and Operartor In C Programming
Expression and Operartor In C Programming
Kamal Acharya
 
C – operators and expressions
C – operators and expressionsC – operators and expressions
C – operators and expressions
Chukka Nikhil Chakravarthy
 
Operator in c programming
Operator in c programmingOperator in c programming
Operator in c programming
Manoj Tyagi
 
C ppt
C pptC ppt
C ppt
jasmeen kr
 
Operators in c programming
Operators in c programmingOperators in c programming
Operators in c programming
savitamhaske
 
Expressions in c++
 Expressions in c++ Expressions in c++
Expressions in c++
zeeshan turi
 
Operation and expression in c++
Operation and expression in c++Operation and expression in c++
Operation and expression in c++
Online
 
Report on c
Report on cReport on c
Report on c
jasmeen kr
 
C# operators
C# operatorsC# operators
Operators in C & C++ Language
Operators in C & C++ LanguageOperators in C & C++ Language
Operators in C & C++ Language
PreSolutions Softwares
 
Precedence and associativity (Computer programming and utilization)
Precedence and associativity (Computer programming and utilization)Precedence and associativity (Computer programming and utilization)
Precedence and associativity (Computer programming and utilization)
Digvijaysinh Gohil
 
Operators in C++
Operators in C++Operators in C++
Operators in C++
Sachin Sharma
 
Chapter 5 - Operators in C++
Chapter 5 - Operators in C++Chapter 5 - Operators in C++
Chapter 5 - Operators in C++
Deepak Singh
 
Operators and expressions in C++
Operators and expressions in C++Operators and expressions in C++
Operators and expressions in C++
Neeru Mittal
 
Operators and Expressions
Operators and ExpressionsOperators and Expressions
Operators and Expressions
Munazza-Mah-Jabeen
 
Operator of C language
Operator of C languageOperator of C language
Operator of C language
Kritika Chauhan
 
Operator.ppt
Operator.pptOperator.ppt
Operator.ppt
Darshan Patel
 
Operators in c++
Operators in c++Operators in c++
Operators in c++
ABHIJITPATRA23
 
Operators and Expressions in Java
Operators and Expressions in JavaOperators and Expressions in Java
Operators and Expressions in Java
Abhilash Nair
 
operators in c++
operators in c++operators in c++
operators in c++
Kartik Fulara
 

What's hot (20)

Expression and Operartor In C Programming
Expression and Operartor In C Programming Expression and Operartor In C Programming
Expression and Operartor In C Programming
 
C – operators and expressions
C – operators and expressionsC – operators and expressions
C – operators and expressions
 
Operator in c programming
Operator in c programmingOperator in c programming
Operator in c programming
 
C ppt
C pptC ppt
C ppt
 
Operators in c programming
Operators in c programmingOperators in c programming
Operators in c programming
 
Expressions in c++
 Expressions in c++ Expressions in c++
Expressions in c++
 
Operation and expression in c++
Operation and expression in c++Operation and expression in c++
Operation and expression in c++
 
Report on c
Report on cReport on c
Report on c
 
C# operators
C# operatorsC# operators
C# operators
 
Operators in C & C++ Language
Operators in C & C++ LanguageOperators in C & C++ Language
Operators in C & C++ Language
 
Precedence and associativity (Computer programming and utilization)
Precedence and associativity (Computer programming and utilization)Precedence and associativity (Computer programming and utilization)
Precedence and associativity (Computer programming and utilization)
 
Operators in C++
Operators in C++Operators in C++
Operators in C++
 
Chapter 5 - Operators in C++
Chapter 5 - Operators in C++Chapter 5 - Operators in C++
Chapter 5 - Operators in C++
 
Operators and expressions in C++
Operators and expressions in C++Operators and expressions in C++
Operators and expressions in C++
 
Operators and Expressions
Operators and ExpressionsOperators and Expressions
Operators and Expressions
 
Operator of C language
Operator of C languageOperator of C language
Operator of C language
 
Operator.ppt
Operator.pptOperator.ppt
Operator.ppt
 
Operators in c++
Operators in c++Operators in c++
Operators in c++
 
Operators and Expressions in Java
Operators and Expressions in JavaOperators and Expressions in Java
Operators and Expressions in Java
 
operators in c++
operators in c++operators in c++
operators in c++
 

Viewers also liked

Increment strategy ppt 2013 14
Increment strategy ppt 2013 14Increment strategy ppt 2013 14
Increment strategy ppt 2013 14
Vipul Saxena
 
An overview of techniques for detecting software variability concepts in sour...
An overview of techniques for detecting software variability concepts in sour...An overview of techniques for detecting software variability concepts in sour...
An overview of techniques for detecting software variability concepts in sour...
Angela Lozano
 
Kerala Service Rules-Part 1
Kerala Service Rules-Part 1Kerala Service Rules-Part 1
Web Engineering
Web EngineeringWeb Engineering
Web Engineering
Abdul Wahid
 
dental cements (3) dental material
dental cements (3) dental materialdental cements (3) dental material
dental cements (3) dental material
Dr-Faisal Al-Qahtani
 
Resume Mcgregor March 2016
Resume Mcgregor March 2016Resume Mcgregor March 2016
Resume Mcgregor March 2016
Arthur McGregor
 
ADO.NET
ADO.NETADO.NET
Operators in c language
Operators in c languageOperators in c language
Operators in c language
Amit Singh
 
Java - Introdução a banco de dados
Java - Introdução a banco de dadosJava - Introdução a banco de dados
Java - Introdução a banco de dados
Sérgio Souza Costa
 
Manual de Usuário - TCC André Luiz Jamarino Abekawa
Manual de Usuário - TCC André Luiz Jamarino AbekawaManual de Usuário - TCC André Luiz Jamarino Abekawa
Manual de Usuário - TCC André Luiz Jamarino Abekawa
André Luiz Jamarino Abekawa
 
Replicacao Object Sistemas
Replicacao Object SistemasReplicacao Object Sistemas
Replicacao Object Sistemas
taniamaciel
 
Minicurso de Cakephp
Minicurso de CakephpMinicurso de Cakephp
Minicurso de Cakephp
Cauan Cabral
 
Junções e subconsultas
Junções e subconsultasJunções e subconsultas
Junções e subconsultas
julianaveregue
 
Apostila PhP com Wamp, 2a. parte
Apostila PhP com Wamp, 2a. parteApostila PhP com Wamp, 2a. parte
Apostila PhP com Wamp, 2a. parte
Ilton Barbosa
 
6. Caracteres; Tipos char e int; Tipos de valor e de referência – Fundamentos...
6. Caracteres; Tipos char e int; Tipos de valor e de referência – Fundamentos...6. Caracteres; Tipos char e int; Tipos de valor e de referência – Fundamentos...
6. Caracteres; Tipos char e int; Tipos de valor e de referência – Fundamentos...
Manuel Menezes de Sequeira
 
Agile Management
Agile ManagementAgile Management
Agile Management
Fábio Aguiar
 
Comment être agile dans un contexte non lié aux TI ?
Comment être agile dans un contexte non lié aux TI ?Comment être agile dans un contexte non lié aux TI ?
Comment être agile dans un contexte non lié aux TI ?
Pyxis Technologies
 
Scrum Guide
Scrum GuideScrum Guide
Scrum Guide
Denis Voituron
 
area econòmica i patrimonial
area econòmica i patrimonialarea econòmica i patrimonial
area econòmica i patrimonial
Sandro
 

Viewers also liked (20)

Increment strategy ppt 2013 14
Increment strategy ppt 2013 14Increment strategy ppt 2013 14
Increment strategy ppt 2013 14
 
An overview of techniques for detecting software variability concepts in sour...
An overview of techniques for detecting software variability concepts in sour...An overview of techniques for detecting software variability concepts in sour...
An overview of techniques for detecting software variability concepts in sour...
 
Kerala Service Rules-Part 1
Kerala Service Rules-Part 1Kerala Service Rules-Part 1
Kerala Service Rules-Part 1
 
Web Engineering
Web EngineeringWeb Engineering
Web Engineering
 
dental cements (3) dental material
dental cements (3) dental materialdental cements (3) dental material
dental cements (3) dental material
 
Resume Mcgregor March 2016
Resume Mcgregor March 2016Resume Mcgregor March 2016
Resume Mcgregor March 2016
 
ADO.NET
ADO.NETADO.NET
ADO.NET
 
Operators in c language
Operators in c languageOperators in c language
Operators in c language
 
Java - Introdução a banco de dados
Java - Introdução a banco de dadosJava - Introdução a banco de dados
Java - Introdução a banco de dados
 
Manual de Usuário - TCC André Luiz Jamarino Abekawa
Manual de Usuário - TCC André Luiz Jamarino AbekawaManual de Usuário - TCC André Luiz Jamarino Abekawa
Manual de Usuário - TCC André Luiz Jamarino Abekawa
 
Replicacao Object Sistemas
Replicacao Object SistemasReplicacao Object Sistemas
Replicacao Object Sistemas
 
Minicurso de Cakephp
Minicurso de CakephpMinicurso de Cakephp
Minicurso de Cakephp
 
Junções e subconsultas
Junções e subconsultasJunções e subconsultas
Junções e subconsultas
 
Apostila PhP com Wamp, 2a. parte
Apostila PhP com Wamp, 2a. parteApostila PhP com Wamp, 2a. parte
Apostila PhP com Wamp, 2a. parte
 
6. Caracteres; Tipos char e int; Tipos de valor e de referência – Fundamentos...
6. Caracteres; Tipos char e int; Tipos de valor e de referência – Fundamentos...6. Caracteres; Tipos char e int; Tipos de valor e de referência – Fundamentos...
6. Caracteres; Tipos char e int; Tipos de valor e de referência – Fundamentos...
 
Agile Management
Agile ManagementAgile Management
Agile Management
 
Comment être agile dans un contexte non lié aux TI ?
Comment être agile dans un contexte non lié aux TI ?Comment être agile dans un contexte non lié aux TI ?
Comment être agile dans un contexte non lié aux TI ?
 
Scrum Guide
Scrum GuideScrum Guide
Scrum Guide
 
area econòmica i patrimonial
area econòmica i patrimonialarea econòmica i patrimonial
area econòmica i patrimonial
 
Lliço5 Cinèticaquímica
Lliço5 CinèticaquímicaLliço5 Cinèticaquímica
Lliço5 Cinèticaquímica
 

Similar to C Prog. - Operators and Expressions

programing in c PPT Gaurav Nautiyal.pptx
programing in c PPT Gaurav Nautiyal.pptxprograming in c PPT Gaurav Nautiyal.pptx
programing in c PPT Gaurav Nautiyal.pptx
Hacker301428
 
Chapter 07
Chapter 07 Chapter 07
Chapter 07
wantedwahab
 
c programming2.pptx
c programming2.pptxc programming2.pptx
c programming2.pptx
YuvarajuCherukuri
 
C operators
C operatorsC operators
C operators
GPERI
 
C operator and expression
C operator and expressionC operator and expression
C operator and expression
LavanyaManokaran
 
cprogrammingoperator.ppt
cprogrammingoperator.pptcprogrammingoperator.ppt
cprogrammingoperator.ppt
georgejustymirobi1
 
C basics
C basicsC basics
C basics
sridevi5983
 
C basics
C basicsC basics
C basics
sridevi5983
 
Operators and Expressions in C#
Operators and Expressions in C#Operators and Expressions in C#
Operators and Expressions in C#
Simplilearn
 
Programming for Problem Solving
Programming for Problem SolvingProgramming for Problem Solving
Programming for Problem Solving
Kathirvel Ayyaswamy
 
Computer programming in C. Library functions in C.
Computer programming in C. Library functions in C.Computer programming in C. Library functions in C.
Computer programming in C. Library functions in C.
LamiyQurbanlKomptert
 
Operator in C language
Operator in C languageOperator in C language
Operator in C language
KanhaiyaSharma52
 
Types of Operators in C
Types of Operators in CTypes of Operators in C
Types of Operators in C
Thesis Scientist Private Limited
 
C++ revision tour
C++ revision tourC++ revision tour
C++ revision tour
Swarup Boro
 
C program
C programC program
C program
AJAL A J
 
Coper in C
Coper in CCoper in C
Coper in C
thirumalaikumar3
 
operator (1).pptx
operator (1).pptxoperator (1).pptx
operator (1).pptx
laptophp39
 
Operator precedence and associativity
Operator precedence and associativityOperator precedence and associativity
Operator precedence and associativity
Dr.Sandhiya Ravi
 
Operator precedence and associativity
Operator precedence and associativityOperator precedence and associativity
Operator precedence and associativity
Dr.Sandhiya Ravi
 
NIKUL SURANI
NIKUL SURANINIKUL SURANI
NIKUL SURANI
Nikul4470
 

Similar to C Prog. - Operators and Expressions (20)

programing in c PPT Gaurav Nautiyal.pptx
programing in c PPT Gaurav Nautiyal.pptxprograming in c PPT Gaurav Nautiyal.pptx
programing in c PPT Gaurav Nautiyal.pptx
 
Chapter 07
Chapter 07 Chapter 07
Chapter 07
 
c programming2.pptx
c programming2.pptxc programming2.pptx
c programming2.pptx
 
C operators
C operatorsC operators
C operators
 
C operator and expression
C operator and expressionC operator and expression
C operator and expression
 
cprogrammingoperator.ppt
cprogrammingoperator.pptcprogrammingoperator.ppt
cprogrammingoperator.ppt
 
C basics
C basicsC basics
C basics
 
C basics
C basicsC basics
C basics
 
Operators and Expressions in C#
Operators and Expressions in C#Operators and Expressions in C#
Operators and Expressions in C#
 
Programming for Problem Solving
Programming for Problem SolvingProgramming for Problem Solving
Programming for Problem Solving
 
Computer programming in C. Library functions in C.
Computer programming in C. Library functions in C.Computer programming in C. Library functions in C.
Computer programming in C. Library functions in C.
 
Operator in C language
Operator in C languageOperator in C language
Operator in C language
 
Types of Operators in C
Types of Operators in CTypes of Operators in C
Types of Operators in C
 
C++ revision tour
C++ revision tourC++ revision tour
C++ revision tour
 
C program
C programC program
C program
 
Coper in C
Coper in CCoper in C
Coper in C
 
operator (1).pptx
operator (1).pptxoperator (1).pptx
operator (1).pptx
 
Operator precedence and associativity
Operator precedence and associativityOperator precedence and associativity
Operator precedence and associativity
 
Operator precedence and associativity
Operator precedence and associativityOperator precedence and associativity
Operator precedence and associativity
 
NIKUL SURANI
NIKUL SURANINIKUL SURANI
NIKUL SURANI
 

More from vinay arora

Search engine and web crawler
Search engine and web crawlerSearch engine and web crawler
Search engine and web crawler
vinay arora
 
Use case diagram (airport)
Use case diagram (airport)Use case diagram (airport)
Use case diagram (airport)
vinay arora
 
Use case diagram
Use case diagramUse case diagram
Use case diagram
vinay arora
 
Lab exercise questions (AD & CD)
Lab exercise questions (AD & CD)Lab exercise questions (AD & CD)
Lab exercise questions (AD & CD)
vinay arora
 
SEM - UML (1st case study)
SEM - UML (1st case study)SEM - UML (1st case study)
SEM - UML (1st case study)
vinay arora
 
6 java - loop
6  java - loop6  java - loop
6 java - loop
vinay arora
 
4 java - decision
4  java - decision4  java - decision
4 java - decision
vinay arora
 
3 java - variable type
3  java - variable type3  java - variable type
3 java - variable type
vinay arora
 
2 java - operators
2  java - operators2  java - operators
2 java - operators
vinay arora
 
1 java - data type
1  java - data type1  java - data type
1 java - data type
vinay arora
 
Uta005 lecture3
Uta005 lecture3Uta005 lecture3
Uta005 lecture3
vinay arora
 
Uta005 lecture1
Uta005 lecture1Uta005 lecture1
Uta005 lecture1
vinay arora
 
Uta005 lecture2
Uta005 lecture2Uta005 lecture2
Uta005 lecture2
vinay arora
 
Security & Protection
Security & ProtectionSecurity & Protection
Security & Protection
vinay arora
 
Process Synchronization
Process SynchronizationProcess Synchronization
Process Synchronization
vinay arora
 
CG - Output Primitives
CG - Output PrimitivesCG - Output Primitives
CG - Output Primitives
vinay arora
 
CG - Display Devices
CG - Display DevicesCG - Display Devices
CG - Display Devices
vinay arora
 
CG - Input Output Devices
CG - Input Output DevicesCG - Input Output Devices
CG - Input Output Devices
vinay arora
 
CG - Introduction to Computer Graphics
CG - Introduction to Computer GraphicsCG - Introduction to Computer Graphics
CG - Introduction to Computer Graphics
vinay arora
 
C Prog. - Strings (Updated)
C Prog. - Strings (Updated)C Prog. - Strings (Updated)
C Prog. - Strings (Updated)
vinay arora
 

More from vinay arora (20)

Search engine and web crawler
Search engine and web crawlerSearch engine and web crawler
Search engine and web crawler
 
Use case diagram (airport)
Use case diagram (airport)Use case diagram (airport)
Use case diagram (airport)
 
Use case diagram
Use case diagramUse case diagram
Use case diagram
 
Lab exercise questions (AD & CD)
Lab exercise questions (AD & CD)Lab exercise questions (AD & CD)
Lab exercise questions (AD & CD)
 
SEM - UML (1st case study)
SEM - UML (1st case study)SEM - UML (1st case study)
SEM - UML (1st case study)
 
6 java - loop
6  java - loop6  java - loop
6 java - loop
 
4 java - decision
4  java - decision4  java - decision
4 java - decision
 
3 java - variable type
3  java - variable type3  java - variable type
3 java - variable type
 
2 java - operators
2  java - operators2  java - operators
2 java - operators
 
1 java - data type
1  java - data type1  java - data type
1 java - data type
 
Uta005 lecture3
Uta005 lecture3Uta005 lecture3
Uta005 lecture3
 
Uta005 lecture1
Uta005 lecture1Uta005 lecture1
Uta005 lecture1
 
Uta005 lecture2
Uta005 lecture2Uta005 lecture2
Uta005 lecture2
 
Security & Protection
Security & ProtectionSecurity & Protection
Security & Protection
 
Process Synchronization
Process SynchronizationProcess Synchronization
Process Synchronization
 
CG - Output Primitives
CG - Output PrimitivesCG - Output Primitives
CG - Output Primitives
 
CG - Display Devices
CG - Display DevicesCG - Display Devices
CG - Display Devices
 
CG - Input Output Devices
CG - Input Output DevicesCG - Input Output Devices
CG - Input Output Devices
 
CG - Introduction to Computer Graphics
CG - Introduction to Computer GraphicsCG - Introduction to Computer Graphics
CG - Introduction to Computer Graphics
 
C Prog. - Strings (Updated)
C Prog. - Strings (Updated)C Prog. - Strings (Updated)
C Prog. - Strings (Updated)
 

Recently uploaded

A beginner’s guide to project reviews - everything you wanted to know but wer...
A beginner’s guide to project reviews - everything you wanted to know but wer...A beginner’s guide to project reviews - everything you wanted to know but wer...
A beginner’s guide to project reviews - everything you wanted to know but wer...
Association for Project Management
 
DANH SÁCH THÍ SINH XÉT TUYỂN SỚM ĐỦ ĐIỀU KIỆN TRÚNG TUYỂN ĐẠI HỌC CHÍNH QUY N...
DANH SÁCH THÍ SINH XÉT TUYỂN SỚM ĐỦ ĐIỀU KIỆN TRÚNG TUYỂN ĐẠI HỌC CHÍNH QUY N...DANH SÁCH THÍ SINH XÉT TUYỂN SỚM ĐỦ ĐIỀU KIỆN TRÚNG TUYỂN ĐẠI HỌC CHÍNH QUY N...
DANH SÁCH THÍ SINH XÉT TUYỂN SỚM ĐỦ ĐIỀU KIỆN TRÚNG TUYỂN ĐẠI HỌC CHÍNH QUY N...
thanhluan21
 
How to Empty a One2Many Field in Odoo 17
How to Empty a One2Many Field in Odoo 17How to Empty a One2Many Field in Odoo 17
How to Empty a One2Many Field in Odoo 17
Celine George
 
RDBMS Lecture Notes Unit4 chapter12 VIEW
RDBMS Lecture Notes Unit4 chapter12 VIEWRDBMS Lecture Notes Unit4 chapter12 VIEW
RDBMS Lecture Notes Unit4 chapter12 VIEW
Murugan Solaiyappan
 
The Cruelty of Animal Testing in the Industry.pdf
The Cruelty of Animal Testing in the Industry.pdfThe Cruelty of Animal Testing in the Industry.pdf
The Cruelty of Animal Testing in the Industry.pdf
luzmilaglez334
 
modul ajar kelas x bahasa inggris 24/254
modul ajar kelas x bahasa inggris 24/254modul ajar kelas x bahasa inggris 24/254
modul ajar kelas x bahasa inggris 24/254
NurFitriah45
 
View Inheritance in Odoo 17 - Odoo 17 Slides
View Inheritance in Odoo 17 - Odoo 17  SlidesView Inheritance in Odoo 17 - Odoo 17  Slides
View Inheritance in Odoo 17 - Odoo 17 Slides
Celine George
 
SD_Integrating 21st Century Skills in Classroom-based Assessment.pptx
SD_Integrating 21st Century Skills in Classroom-based Assessment.pptxSD_Integrating 21st Century Skills in Classroom-based Assessment.pptx
SD_Integrating 21st Century Skills in Classroom-based Assessment.pptx
elwoodprias1
 
FINAL MATATAG Kindergarten CG 2023 pdf
FINAL MATATAG Kindergarten CG 2023   pdfFINAL MATATAG Kindergarten CG 2023   pdf
FINAL MATATAG Kindergarten CG 2023 pdf
maricelrudela
 
BÀI TẬP BỔ TRỢ 4 KỸ NĂNG TIẾNG ANH LỚP 12 - GLOBAL SUCCESS - FORM MỚI 2025 - ...
BÀI TẬP BỔ TRỢ 4 KỸ NĂNG TIẾNG ANH LỚP 12 - GLOBAL SUCCESS - FORM MỚI 2025 - ...BÀI TẬP BỔ TRỢ 4 KỸ NĂNG TIẾNG ANH LỚP 12 - GLOBAL SUCCESS - FORM MỚI 2025 - ...
BÀI TẬP BỔ TRỢ 4 KỸ NĂNG TIẾNG ANH LỚP 12 - GLOBAL SUCCESS - FORM MỚI 2025 - ...
Nguyen Thanh Tu Collection
 
Mail Server Configuration Using App passwords in Odoo 17
Mail Server Configuration Using App passwords in Odoo 17Mail Server Configuration Using App passwords in Odoo 17
Mail Server Configuration Using App passwords in Odoo 17
Celine George
 
"DANH SÁCH THÍ SINH XÉT TUYỂN SỚM ĐỦ ĐIỀU KIỆN TRÚNG TUYỂN ĐẠI HỌC CHÍNH QUY ...
"DANH SÁCH THÍ SINH XÉT TUYỂN SỚM ĐỦ ĐIỀU KIỆN TRÚNG TUYỂN ĐẠI HỌC CHÍNH QUY ..."DANH SÁCH THÍ SINH XÉT TUYỂN SỚM ĐỦ ĐIỀU KIỆN TRÚNG TUYỂN ĐẠI HỌC CHÍNH QUY ...
"DANH SÁCH THÍ SINH XÉT TUYỂN SỚM ĐỦ ĐIỀU KIỆN TRÚNG TUYỂN ĐẠI HỌC CHÍNH QUY ...
thanhluan21
 
Odoo 17 Events - Attendees List Scanning
Odoo 17 Events - Attendees List ScanningOdoo 17 Events - Attendees List Scanning
Odoo 17 Events - Attendees List Scanning
Celine George
 
Benchmarking Sustainability: Neurosciences and AI Tech Research in Macau - Ke...
Benchmarking Sustainability: Neurosciences and AI Tech Research in Macau - Ke...Benchmarking Sustainability: Neurosciences and AI Tech Research in Macau - Ke...
Benchmarking Sustainability: Neurosciences and AI Tech Research in Macau - Ke...
Alvaro Barbosa
 
E-learning Odoo 17 New features - Odoo 17 Slides
E-learning Odoo 17  New features - Odoo 17 SlidesE-learning Odoo 17  New features - Odoo 17 Slides
E-learning Odoo 17 New features - Odoo 17 Slides
Celine George
 
modul ajar kelas x bahasa inggris 2024-2025
modul ajar kelas x bahasa inggris 2024-2025modul ajar kelas x bahasa inggris 2024-2025
modul ajar kelas x bahasa inggris 2024-2025
NurFitriah45
 
C Interview Questions PDF By Scholarhat.pdf
C Interview Questions PDF By Scholarhat.pdfC Interview Questions PDF By Scholarhat.pdf
C Interview Questions PDF By Scholarhat.pdf
Scholarhat
 
Genetics Teaching Plan: Dr.Kshirsagar R.V.
Genetics Teaching Plan: Dr.Kshirsagar R.V.Genetics Teaching Plan: Dr.Kshirsagar R.V.
Genetics Teaching Plan: Dr.Kshirsagar R.V.
DrRavindrakshirsagar1
 
matatag curriculum education for Kindergarten
matatag curriculum education for Kindergartenmatatag curriculum education for Kindergarten
matatag curriculum education for Kindergarten
SarahAlie1
 
Power of Ignored Skills: Change the Way You Think and Decide by Manoj Tripathi
Power of Ignored Skills: Change the Way You Think and Decide by Manoj TripathiPower of Ignored Skills: Change the Way You Think and Decide by Manoj Tripathi
Power of Ignored Skills: Change the Way You Think and Decide by Manoj Tripathi
Pankaj523992
 

Recently uploaded (20)

A beginner’s guide to project reviews - everything you wanted to know but wer...
A beginner’s guide to project reviews - everything you wanted to know but wer...A beginner’s guide to project reviews - everything you wanted to know but wer...
A beginner’s guide to project reviews - everything you wanted to know but wer...
 
DANH SÁCH THÍ SINH XÉT TUYỂN SỚM ĐỦ ĐIỀU KIỆN TRÚNG TUYỂN ĐẠI HỌC CHÍNH QUY N...
DANH SÁCH THÍ SINH XÉT TUYỂN SỚM ĐỦ ĐIỀU KIỆN TRÚNG TUYỂN ĐẠI HỌC CHÍNH QUY N...DANH SÁCH THÍ SINH XÉT TUYỂN SỚM ĐỦ ĐIỀU KIỆN TRÚNG TUYỂN ĐẠI HỌC CHÍNH QUY N...
DANH SÁCH THÍ SINH XÉT TUYỂN SỚM ĐỦ ĐIỀU KIỆN TRÚNG TUYỂN ĐẠI HỌC CHÍNH QUY N...
 
How to Empty a One2Many Field in Odoo 17
How to Empty a One2Many Field in Odoo 17How to Empty a One2Many Field in Odoo 17
How to Empty a One2Many Field in Odoo 17
 
RDBMS Lecture Notes Unit4 chapter12 VIEW
RDBMS Lecture Notes Unit4 chapter12 VIEWRDBMS Lecture Notes Unit4 chapter12 VIEW
RDBMS Lecture Notes Unit4 chapter12 VIEW
 
The Cruelty of Animal Testing in the Industry.pdf
The Cruelty of Animal Testing in the Industry.pdfThe Cruelty of Animal Testing in the Industry.pdf
The Cruelty of Animal Testing in the Industry.pdf
 
modul ajar kelas x bahasa inggris 24/254
modul ajar kelas x bahasa inggris 24/254modul ajar kelas x bahasa inggris 24/254
modul ajar kelas x bahasa inggris 24/254
 
View Inheritance in Odoo 17 - Odoo 17 Slides
View Inheritance in Odoo 17 - Odoo 17  SlidesView Inheritance in Odoo 17 - Odoo 17  Slides
View Inheritance in Odoo 17 - Odoo 17 Slides
 
SD_Integrating 21st Century Skills in Classroom-based Assessment.pptx
SD_Integrating 21st Century Skills in Classroom-based Assessment.pptxSD_Integrating 21st Century Skills in Classroom-based Assessment.pptx
SD_Integrating 21st Century Skills in Classroom-based Assessment.pptx
 
FINAL MATATAG Kindergarten CG 2023 pdf
FINAL MATATAG Kindergarten CG 2023   pdfFINAL MATATAG Kindergarten CG 2023   pdf
FINAL MATATAG Kindergarten CG 2023 pdf
 
BÀI TẬP BỔ TRỢ 4 KỸ NĂNG TIẾNG ANH LỚP 12 - GLOBAL SUCCESS - FORM MỚI 2025 - ...
BÀI TẬP BỔ TRỢ 4 KỸ NĂNG TIẾNG ANH LỚP 12 - GLOBAL SUCCESS - FORM MỚI 2025 - ...BÀI TẬP BỔ TRỢ 4 KỸ NĂNG TIẾNG ANH LỚP 12 - GLOBAL SUCCESS - FORM MỚI 2025 - ...
BÀI TẬP BỔ TRỢ 4 KỸ NĂNG TIẾNG ANH LỚP 12 - GLOBAL SUCCESS - FORM MỚI 2025 - ...
 
Mail Server Configuration Using App passwords in Odoo 17
Mail Server Configuration Using App passwords in Odoo 17Mail Server Configuration Using App passwords in Odoo 17
Mail Server Configuration Using App passwords in Odoo 17
 
"DANH SÁCH THÍ SINH XÉT TUYỂN SỚM ĐỦ ĐIỀU KIỆN TRÚNG TUYỂN ĐẠI HỌC CHÍNH QUY ...
"DANH SÁCH THÍ SINH XÉT TUYỂN SỚM ĐỦ ĐIỀU KIỆN TRÚNG TUYỂN ĐẠI HỌC CHÍNH QUY ..."DANH SÁCH THÍ SINH XÉT TUYỂN SỚM ĐỦ ĐIỀU KIỆN TRÚNG TUYỂN ĐẠI HỌC CHÍNH QUY ...
"DANH SÁCH THÍ SINH XÉT TUYỂN SỚM ĐỦ ĐIỀU KIỆN TRÚNG TUYỂN ĐẠI HỌC CHÍNH QUY ...
 
Odoo 17 Events - Attendees List Scanning
Odoo 17 Events - Attendees List ScanningOdoo 17 Events - Attendees List Scanning
Odoo 17 Events - Attendees List Scanning
 
Benchmarking Sustainability: Neurosciences and AI Tech Research in Macau - Ke...
Benchmarking Sustainability: Neurosciences and AI Tech Research in Macau - Ke...Benchmarking Sustainability: Neurosciences and AI Tech Research in Macau - Ke...
Benchmarking Sustainability: Neurosciences and AI Tech Research in Macau - Ke...
 
E-learning Odoo 17 New features - Odoo 17 Slides
E-learning Odoo 17  New features - Odoo 17 SlidesE-learning Odoo 17  New features - Odoo 17 Slides
E-learning Odoo 17 New features - Odoo 17 Slides
 
modul ajar kelas x bahasa inggris 2024-2025
modul ajar kelas x bahasa inggris 2024-2025modul ajar kelas x bahasa inggris 2024-2025
modul ajar kelas x bahasa inggris 2024-2025
 
C Interview Questions PDF By Scholarhat.pdf
C Interview Questions PDF By Scholarhat.pdfC Interview Questions PDF By Scholarhat.pdf
C Interview Questions PDF By Scholarhat.pdf
 
Genetics Teaching Plan: Dr.Kshirsagar R.V.
Genetics Teaching Plan: Dr.Kshirsagar R.V.Genetics Teaching Plan: Dr.Kshirsagar R.V.
Genetics Teaching Plan: Dr.Kshirsagar R.V.
 
matatag curriculum education for Kindergarten
matatag curriculum education for Kindergartenmatatag curriculum education for Kindergarten
matatag curriculum education for Kindergarten
 
Power of Ignored Skills: Change the Way You Think and Decide by Manoj Tripathi
Power of Ignored Skills: Change the Way You Think and Decide by Manoj TripathiPower of Ignored Skills: Change the Way You Think and Decide by Manoj Tripathi
Power of Ignored Skills: Change the Way You Think and Decide by Manoj Tripathi
 

C Prog. - Operators and Expressions

  • 1. C Programming - Operators and Expressions 2 Copyright © 2010 Dorling Kindersley (India) Pvt. Ltd.
  • 2. Programming in C: A Practical Approach Operators and Expressions Expressions An expression in C is made up of one or more operands. The simplest form of an expression consists of a single operand. For example, 3 is an expression that consists of a single operand i.e. 3. Such an expression does not specify any operation to be performed and is not meaningful. For example, a=2+3 // meaningful expression Involves three operands :a, 2 and 3 Two operators i.e. = (assignment operator) and + (arithmetic addition operator). Thus, an expression is a sequence of operands and operators that specifies the computation of a value. Copyright © 2010 Dorling Kindersley (India) Pvt. Ltd.
  • 3. Programming in C: A Practical Approach Operators and Expressions Operands An operand specifies an entity on which an operation is to be performed. An operand can be a variable name, a constant. For example, a=b+2 is a valid expression involving three operands namely, a variable name i.e. a, a variable name i.e. b, a constant i.e. 2. Copyright © 2010 Dorling Kindersley (India) Pvt. Ltd.
  • 4. Programming in C: A Practical Approach Operators and Expressions Operators An operator specifies the operation to be applied to its operands. For example, the expression: a=b+2; involves two operators namely, arithmetic addition operator i.e. + assignment operator i.e. =.   Based on the number of operators present in an expression, expressions are classified as simple expressions and compound expressions. Copyright © 2010 Dorling Kindersley (India) Pvt. Ltd.
  • 5. Simple and Compound Expressions Programming in C: A Practical Approach Operators and Expressions Simple Expressions An expression that has only one operator is known as simple expression . E.g., a+2 is a simple expression. Evaluation of simple expression is easier as order of determination is trivial in this case as there is only one operator. Compound Expressions An expression that involves more than one operator is called compound expression. E.g. b=2+3*5 is a compound expression. Whereas the evaluation of a compound expression requires the correct order in which the operators will operate. This depends upon the Precedence and the Associativity of operators. Copyright © 2010 Dorling Kindersley (India) Pvt. Ltd.
  • 6. Precedence of Operators Each operator in C has a precedence associated with it. In a compound expression, if the operators involved are of different precedence, the operator of higher precedence is evaluated first. For example, in an expression b=2+3*5, The sub-expression 3*5 involving multiplication operator (i.e. *). The result of evaluation of an expression is an r-value. The sub-expression 3*5 evaluates to an r-value 15. This r-value will act as second operand for addition operator and the expression becomes b=2+15. Programming in C: A Practical Approach Operators and Expressions Copyright © 2010 Dorling Kindersley (India) Pvt. Ltd.
  • 7. Programming in C: A Practical Approach Operators and Expressions In the resultant expression, the sub-expression 2+15. The expression after the evaluation of the addition operator reduces to b=17. Now, there is only one operator in the expression. The assignment operator will operate and the value 17 is assigned to b. The precedence order is * > + > =. The knowledge of precedence of operators alone is not sufficient to evaluate a compound expression in case two or more operators involved are of same precedence. To determine which of these operators will operate first, the Associativity of these operators is to be considered. Copyright © 2010 Dorling Kindersley (India) Pvt. Ltd.
  • 8. Programming in C: A Practical Approach Operators and Expressions Associativity of Operators Key Points An operator can be either left-to-right associative or right-to-left associative. The operators with same precedence always have the same associativity. If operators are left-to-right associative, they are applied in left-to-right order i.e. the operator which appears towards left will be evaluated first. If they are right-to-left associative, they will be applied in the right-to-left order. The multiplication and the division operators are left-to-right associative. Hence, in expression 2*3/5, the multiplication operator is evaluated prior to the division operator as it appears before the division operator in left-to-right order. Copyright © 2010 Dorling Kindersley (India) Pvt. Ltd.
  • 9. Classification of Operators Programming in C: A Practical Approach Operators and Expressions Copyright © 2010 Dorling Kindersley (India) Pvt. Ltd. TERNARY OPERATOR BINARY OPERATOR UNARY OPERATOR BASED ON NO. OF OPERATORS BASED ON ROLE OF OPERATOR BITWISE OPERATORS MISCELLANEOUS OPERATORS ARITHMETIC OPERATORS ASSIGNMENT OPERATORS LOGICAL OPERATORS RELATIONAL OPERATORS CLASSIFICATION OF OPERATORS
  • 10. Based on No. of Operators Unary Operators Unary operator operates on only one operand. For example, in the expression -3, - is unary minus operator as it operates on only one operand i.e. 3. The operand can be present towards the right of unary operator, as in -3 or towards the left of unary operator, as in the expression a++. Examples of unary operators are: & (address-of operator) sizeof operator ! (logical negation) ~ (bitwise negation) ++ (increment operator) -- (decrement operator) etc. Programming in C: A Practical Approach Operators and Expressions Copyright © 2010 Dorling Kindersley (India) Pvt. Ltd.
  • 11. Binary Operators Binary operator operates on two operands. It requires an operand towards its left and right. For example, in expression 2-3 - is acting as binary minus operator as it is operating on two operands i.e. 2 and 3. Examples of binary operators are: * (multiplication operator), / (division operator), << (left shift operator), == (equality operator), && (logical AND), & (bitwise AND) etc. Programming in C: A Practical Approach Operators and Expressions Copyright © 2010 Dorling Kindersley (India) Pvt. Ltd.
  • 12. Ternary Operators Ternary operator operates on three operands. Conditional operator (i.e. ? :) is the only ternary operator available in C. Programming in C: A Practical Approach Operators and Expressions Copyright © 2010 Dorling Kindersley (India) Pvt. Ltd.
  • 13. Based on Role Of Operator Arithmetic Operators The arithmetic operations like addition, subtraction, multiplication, division etc. can be performed by using arithmetic operators. Following arithmetic operators are available in C: Programming in C: A Practical Approach Operators and Expressions Copyright © 2010 Dorling Kindersley (India) Pvt. Ltd. The operators within a row have the same precedence and the order in which they are written does not matter. S.No Operator Name of Operator Category -ary of Operators Precedence amongst arithmetic class Associativity 1. + - ++ -- Unary plus Unary minus Increment Decrement Unary operators Unary Level-I (Highest) R->L (Right-to-left) 2. * / % Multiplication Division Modulus Multiplicative operators Binary Level-II (Intermediate) L->R (Left-to-right) 3. + - Addition Subtraction Additive operators Binary Level-III (Lowest) L->R
  • 14. Key Points: Arithmetic Operators The parenthesized sub-expressions are evaluated first. If the parentheses are nested, the innermost sub-expression is evaluated first. The precedence rules are applied to determine the order of application of operators while evaluating sub-expressions. The associativity rule is applied when two or more operators of the same precedence appear in the sub-expression. If the operands of a binary arithmetic operator are of different but compatible types, C automatically applies arithmetic type conversion to bring the operands to a common type. This automatic type conversion is known as implicit type conversion . The result Programming in C: A Practical Approach Operators and Expressions Copyright © 2010 Dorling Kindersley (India) Pvt. Ltd.
  • 15. of evaluation of operator will be of common type . The basic principle behind the implicit arithmetic type conversion is that if operands are of different types, the lower type (i.e. smaller in size) should be converted to a higher type (i.e. bigger in size) so that there is no loss in value or precision. Since, a lower type is converted to a higher type, it is said that lower type is promoted to a higher type and the conversion is known as promotion . Programming in C: A Practical Approach Operators and Expressions Copyright © 2010 Dorling Kindersley (India) Pvt. Ltd.
  • 16. Arithmetic Type Conversions If one operand is long double, the other will be converted to long double and the result will be long double. If one operand is double, the other will be converted to double and the result will be double. If one operand is float, the other will be converted to float and the result will be float. If one of the operands is unsigned long int, the other will be converted to unsigned long int and the result will be unsigned long int. Programming in C: A Practical Approach Operators and Expressions Copyright © 2010 Dorling Kindersley (India) Pvt. Ltd.
  • 17. If one operand is long int and other is unsigned int then If unsigned int can be converted to long int, then unsigned int operand will be converted as such and the result will be long int. Else, both operands will be converted to unsigned long int and the result will be unsigned long int. If one of the operands is long int, the other will be converted to long int and the result will be long int. If one operand is unsigned int, the other will be converted to unsigned int and the result will be unsigned int. If none of the above is carried out, both the operands are converted to int. Programming in C: A Practical Approach Operators and Expressions Copyright © 2010 Dorling Kindersley (India) Pvt. Ltd.
  • 18. Key Points: Arithmetic Operators 1. The unary plus operator can appear only towards the left side of its operand. 2. The unary minus operator can appear only towards the left side of its operand. 3. Increment operator The increment operator can appear towards the left side or towards the right side of its operand. If it appears towards the left side of its operand (e.g. ++a), it is known as pre-increment operator . If it appears towards the right side of its operand (e.g. a++), it is known as post-increment operator . The increment operator can only be applied to an operand that has a modifiable L-value. If it is applied to an operand that does not have a modifiable L-value, there will be “L-value required” error. Programming in C: A Practical Approach Operators and Expressions Copyright © 2010 Dorling Kindersley (India) Pvt. Ltd.
  • 19. ++a or a++ is equivalent to a=a+1. The difference between pre-increment and post-increment lies in the point at which the value of their operand is incremented. In case of pre-increment operator, first the value of its operand is incremented and then it is used for the evaluation of expression. In case of post-increment operator, the value of operand is used first for the evaluation of the expression and after its use, the value of the operand is incremented. Increment operator is a token i.e. one unit. There should be no white space character between two ‘+’ symbols. If white space is placed between two ‘+’ symbols, they become two unary plus (+) operators. Programming in C: A Practical Approach Operators and Expressions Copyright © 2010 Dorling Kindersley (India) Pvt. Ltd.
  • 20. Programming in C: A Practical Approach Operators and Expressions Tokens are the basic building blocks of a source code. Characters are combined into tokens according to the rules of the programming language. There are five classes of tokens: identifiers, reserved words, operators, separators and constants. Copyright © 2010 Dorling Kindersley (India) Pvt. Ltd. 4. Decrement operator The decrement operator can appear towards the left side or towards the right side of its operand. If it appears towards the left side of its operand (e.g. --a), it is known as pre-decrement operator . If it appears towards the right side of its operand (e.g. a--), it is known as post-decrement operator. The decrement operator can only be applied to an operand that has a modifiable L-value. If it is applied on an operand that does not have a modifiable L-value, there will be a compilation error “L-value required”.
  • 21. --a or a-- is equivalent to a=a-1. The difference between pre-decrement and post-decrement lies in the point at which the value of their operand is decremented. In case of pre-decrement operator, firstly the value of its operand is decremented and then used for the evaluation of the expression in which it appears. In case of post-decrement operator, firstly the value of operand is used for the evaluation of the expression in which it appears and then, its value is decremented. Decrement operator is a token i.e. one unit. There should be no white space character between two ‘-’ symbols. If white space is placed between two ‘-’ symbols, they become two unary minus (-) operators. Programming in C: A Practical Approach Operators and Expressions Copyright © 2010 Dorling Kindersley (India) Pvt. Ltd.
  • 22. 5. Division operator The division operator is used to find the quotient. The sign of the result of evaluation of division operator depends upon the sign of both numerator as well as denominator. If both are positive, the result will be positive. If both are negative, the result will be positive. If either of the two is negative, the result will be negative. For example: 4/3=1, -4/3=-1, 4/-3=-1 and -4/-3=1. 6. Modulus operator The modulus operator is used to find the remainder. The operands of modulus operator (i.e. %) must be of integer type. Modulus operator cannot have operands of floating point type. The sign of the result of evaluation of modulus operator depends only upon the sign of numerator. If sign of numerator is positive, the sign of result will be positive else negative. For example: 4%3=1, -4%3=-1, 4%-3=1 and -4%-3=-1. Programming in C: A Practical Approach Operators and Expressions Copyright © 2010 Dorling Kindersley (India) Pvt. Ltd.
  • 23. Relational Operators Relational operators are used to compare two quantities (i.e. their operands). There are six relational operators in C: Programming in C: A Practical Approach Operators and Expressions Copyright © 2010 Dorling Kindersley (India) Pvt. Ltd. S.No Operator Name of Operator Category -ary of Operators Precedence amongst relational class Associativity 1. < > <= >= Less than Greater than Less than or equal to Greater than or equal to Relational operators Binary Level-I L->R 2. == != Equal to Not equal to Equality operators Binary Level-II L->R
  • 24. Key Points: Relational Operators There should be no white space character between two symbols of a relational operator. The result of evaluation of a relational expression (i.e. involving relational operator) is a boolean constant i.e. 0 or 1. Each of the relational operators yields 1 if the specified relation is true and 0 if it is false. The result has type int. The expression a<b<c is valid and is not interpreted as in ordinary mathematics. Since, less than operator (i.e. <) is left-to-right associative, the expression is interpreted as (a<b)<c. This means that “if a is less than b, compare 1 with c, otherwise, compare 0 with c”. An expression that involves a relational operator forms a condition . For example, a<b is a condition. Programming in C: A Practical Approach Operators and Expressions Copyright © 2010 Dorling Kindersley (India) Pvt. Ltd.
  • 25. Logical Operators Logical operators are used to logically relate the expressions. The C language has the following logical operators:  In C language, there is no operator available for logical eXclusive-OR (XOR) operation. Programming in C: A Practical Approach Operators and Expressions Copyright © 2010 Dorling Kindersley (India) Pvt. Ltd. S.No Operator Name of Operator Category -ary of Operators Precedence amongst logical class Associativity 1. ! Logical NOT Unary Unary Level-I R->L 2. && Logical AND Logical operator Binary Level-II L->R 3. || Logical OR Logical operator Binary Level-III L->R
  • 26. Key Points: Logical Operators Logical operators consider operand as an entity, a unit. Logical operators operate according to the following truth tables: Programming in C: A Practical Approach Operators and Expressions Copyright © 2010 Dorling Kindersley (India) Pvt. Ltd. OPERAND 1 OPERAND 2 AND OPERATION OR OPERATION FALSE FALSE FALSE FALSE FALSE TRUE FALSE TRUE TRUE FALSE FALSE TRUE TRUE TRUE TRUE TRUE OPERAND NOT OPERATION FALSE TRUE TRUE FALSE
  • 27. If an operand of a logical operator is a non-zero value, the operand is considered as true. If operand is zero, it is considered as false. Each of the logical operators yields 1 if the specified relation evaluates to true and 0 if it evaluates to false. The evaluation is done according to the truth tables mentioned in previous slide. The result has type int. The logical AND (i.e. &&) operator and the logical OR (i.e. ||) operator guarantee left to right evaluation. Expressions connected by && or || are evaluated left to right and the evaluation stops as soon as truthfulness or falsehood of the result is Programming in C: A Practical Approach Operators and Expressions Copyright © 2010 Dorling Kindersley (India) Pvt. Ltd.
  • 28. known. Thus, in an expression: E1&&E2, where E1 and E2 are sub-expressions, E1 is evaluated first. If E1 evaluates to 0 (i.e. false), E2 will not be evaluated and the result of overall expression will be 0 (i.e. false). If E1 evaluates to a non-zero value (i.e. true) then E2 will be evaluated to determine the truth value of overall expression. E1||E2, where E1 and E2 are sub-expressions, E1 is evaluated first. If E1 evaluates to a non-zero value (i.e. true), E2 will not be evaluated and the result of overall expression will be 1 (i.e. true). If E1 evaluates to 0 (i.e. false) then E2 will be evaluated to determine the truth value of overall expression. Programming in C: A Practical Approach Operators and Expressions Copyright © 2010 Dorling Kindersley (India) Pvt. Ltd.
  • 29. Bitwise Operators The C language provides six operators for bit manipulation. These operators do not consider operand as one entity and operate on the individual bits of operands. The following bitwise operators are available in C: Programming in C: A Practical Approach Operators and Expressions Copyright © 2010 Dorling Kindersley (India) Pvt. Ltd. S.No Operator Name of Operator Category -ary of Operators Precedence amongst bitwise class Associativity 1. ~ Bitwise NOT Unary Unary Level-I R->L 2. << >> Left Shift Right Shift Shift operators Binary Level-II L->R 3. & Bitwise AND Bitwise operator Binary Level-III L->R 4. ^ Bitwise X-OR Bitwise operator Binary Level-IV L->R 5. | Bitwise OR Bitwise operator Binary Level-V L->R
  • 30. Assignment Operators A variable can be assigned a value by using assignment operator. The following assignment operators are available in C language: Programming in C: A Practical Approach Operators and Expressions Copyright © 2010 Dorling Kindersley (India) Pvt. Ltd. S. No Operator Name of Operator Category -ary of Operators Precedence Associativity 1. = *= /= %= += -= &= |= ^= <<= >>= Simple assignment Assign product Assign quotient Assign modulus Assign sum Assign difference Assign bitwise AND Assign bitwise OR Assign bitwise XOR Assign left shift Assign right shift Assignment Shorthand assignment operators Binary Level-I R->L
  • 31. Key Points: Assignment Operators The operand that appears towards the left side of an assignment operator should have a modifiable l-value. If the operand appearing towards the left side of the assignment operator does not have modifiable l-value, there will be a compilation error “L-value required”. The shorthand assignment is of the form op1 op=op2, where op1 and op2 are operands and op= is a shorthand assignment operator. It is a shorter way of writing op1 = op1 op op2. For example, a/=2 is equivalent to a=a/2.  There should be no white space character between two symbols of short-hand assignment operators. If two operands of an assignment operator are of different types, the type of operand on the right side of assignment operator is Programming in C: A Practical Approach Operators and Expressions Copyright © 2010 Dorling Kindersley (India) Pvt. Ltd.
  • 32. automatically converted to the type of operand present on its left side. To carry out this conversion, either promotion or demotion is applied. The terms assignment and initialization are related but it is important to note the differences between them: Programming in C: A Practical Approach Operators and Expressions Copyright © 2010 Dorling Kindersley (India) Pvt. Ltd. S.No Initialization Assignment 1. First time assignment at the time of definition is called initialization. For example: int a=10; is initialization of a . Value of a data object after initialization can be changed by the means of assignment. For example: Consider the following statements int a=10; a=20; The value of a is changed to 20 by the assignment statement. 2. Initialization can be done only once. Assignment can be done any number of times. 3. Qualified constant can be initialized with a value. For example, const int a=10; is valid. Qualified constant cannot be assigned a value. It is erroneous to write a=10; if a is a qualified constant.
  • 33. Miscellaneous Operators Other operators available in C are: Function call operator (i.e. ()) Array subscript operator (i.e. []) Member select operator Direct member access operator (i.e. . (dot operator or period)) Indirect member access operator (i.e. -> (arrow operator)) Indirection operator (i.e. *) Conditional operator Comma operator sizeof operator Address-of operator (i.e. &) Programming in C: A Practical Approach Operators and Expressions Copyright © 2010 Dorling Kindersley (India) Pvt. Ltd.
  • 34. Sizeof Operator The sizeof operator is used to determine the size in bytes that a value or a data object will take in memory. The following are the important points about sizeof operator: The general form of sizeof operator is: sizeof expression or sizeof (expression) (For example: sizeof 2, sizeof(a), sizeof(2+3)) sizeof (type-name) (For example: sizeof(int), sizeof(int*), sizeof(char)) Programming in C: A Practical Approach Operators and Expressions Copyright © 2010 Dorling Kindersley (India) Pvt. Ltd. S.No Operator Name of Operator Category ary of Operators Precedence Associativity 1. sizeof Size-of operator Unary Unary Level-I R->L
  • 35. Parentheses are must if sizeof operator is applied on a type-name, as indicated in the point 1 b) above. The type of result of evaluation of sizeof operator is int. The operand of sizeof operator is not evaluated. The sizeof operator cannot be applied on operands of incomplete type or function type. Programming in C: A Practical Approach Operators and Expressions Copyright © 2010 Dorling Kindersley (India) Pvt. Ltd.
  • 36. Combined Precedence of All Operators Till now we have discussed intra-class precedence, now we will discuss the inter-class precedence Programming in C: A Practical Approach Operators and Expressions Copyright © 2010 Dorling Kindersley (India) Pvt. Ltd. S.No Operator Name of Operator Category -ary of Operators Precedence Associativity 1. () [] -> . Function call Array subscript Indirect member access Direct member access Level-I (Highest) 2. ! ~ + - ++ -- & * sizeof Logical NOT Bitwise NOT Unary plus Unary minus Increment Decrement Address-of Deference Sizeof Unary Unary Level-II R->L 3. * / % Multiplication Division Modulus Multiplicative operators Binary Level-III L->R
  • 37. Programming in C: A Practical Approach Operators and Expressions Copyright © 2010 Dorling Kindersley (India) Pvt. Ltd. S.No Operator Name of Operator Category ary of Operators Precedence Associativity 4. + - Addition Subtraction Additive operators Binary Level-IV L->R 5. << >> Left Shift Right Shift Shift operators Binary Level-V L->R 6. < > <= >= Less than Greater than Less than or equal to Greater than or equal to Relational operators Binary Level-VI L->R 7. == != Equal to Not equal to Equality operators Binary Level-VII L->R 8. & Bitwise AND Bitwise operator Binary Level-VIII L->R 9. ^ Bitwise X-OR Bitwise operator Binary Level-IX L->R 10. | Bitwise OR Bitwise operator Binary Level-X L->R 11. && Logical AND Logical operator Binary Level-XI L->R 12. || Logical OR Logical operator Binary Level-XII L->R 13. ?: Conditional operator Conditional Ternary Level-XIII R->L
  • 38. Programming in C: A Practical Approach Operators and Expressions Copyright © 2010 Dorling Kindersley (India) Pvt. Ltd. S.No Operator Name of Operator Category ary of Operators Precedence Associativity 14. = *= /= %= += -= &= |= ^= <<= >>= Simple assignment Assign product Assign quotient Assign modulus Assign sum Assign difference Assign bitwise AND Assign bitwise OR Assign bitwise XOR Assign left shift Assign right shift Assignment & Shorthand assignment operators Binary Level-XIV R->L 15. , Comma operator Comma Binary Level-XV (Least) L->R