The document discusses operator precedence and associativity in C. It covers comparison, arithmetic, assignment, increment/decrement, bitwise, and logical operators. For each operator, it provides the symbol, description, examples, and order of precedence from highest to lowest. It also gives examples of how to use various operators in code snippets.
4. operators in c programming by digital waveRahulSharma4566
For Video Tutorial Click on Link:
https://youtu.be/u9eSpH3NTFg
https://youtu.be/mzxYbU4t2VY
https://youtu.be/Xv5nPe2y2w8
Bitwise Operators
Advance and Basic concepts of C PRogramming
Bitwise AND, OR, XOR, NOT, RIGHT & LEFT SHIFT
What is Bitwise Operator?
What are the types of Bitwise operators?
What is the Bitwise AND operator?
What is the Bitwise OR operator?
What is Operator?
What are the types of operators?
What is the unary operator?
What are the types of unary operators?
What is Post Increment Operator
What is Pre Increment Operator?
Unary Operators
Relational Operators
Logical Operators
Digital Wave
#OperatorsinCProgramming
#typesofoperatorincprogramming
#Relational OperatorinC
# LogicalOperatorinC
# LogicalANDoperatorinc
# LogicalOROperatorinc
# LogicalXOROperator
#IntroductionofProgammingInC
This presentation contain description about C Operators.
It explains Arithmetic operators, relational operators, logical operators, increment/decrement operators, conditional and bitwise operators are explained with example.
4. operators in c programming by digital waveRahulSharma4566
For Video Tutorial Click on Link:
https://youtu.be/u9eSpH3NTFg
https://youtu.be/mzxYbU4t2VY
https://youtu.be/Xv5nPe2y2w8
Bitwise Operators
Advance and Basic concepts of C PRogramming
Bitwise AND, OR, XOR, NOT, RIGHT & LEFT SHIFT
What is Bitwise Operator?
What are the types of Bitwise operators?
What is the Bitwise AND operator?
What is the Bitwise OR operator?
What is Operator?
What are the types of operators?
What is the unary operator?
What are the types of unary operators?
What is Post Increment Operator
What is Pre Increment Operator?
Unary Operators
Relational Operators
Logical Operators
Digital Wave
#OperatorsinCProgramming
#typesofoperatorincprogramming
#Relational OperatorinC
# LogicalOperatorinC
# LogicalANDoperatorinc
# LogicalOROperatorinc
# LogicalXOROperator
#IntroductionofProgammingInC
This presentation contain description about C Operators.
It explains Arithmetic operators, relational operators, logical operators, increment/decrement operators, conditional and bitwise operators are explained with example.
Aggregate functions are functions that take a collection of values as input and return a single value.The ISO standard defines five (5) aggregate functions namely :-
1) COUNT
2) SUM
3) AVG
4) MIN
5) MAX
1.COUNT Function
The COUNT function returns the total number of values in the specified field. It works on both numeric and non-numeric data types. All aggregate functions by default exclude nulls values before working on the data.
MIN function
The MIN function returns the smallest value in the specified table field.
2.MAX function
Just as the name suggests, the MAX function is the opposite of the MIN function. It returns the largest value from the specified table field.
3.SUM function
Suppose we want a report that gives total amount of payments made so far. We can use the MySQL SUM function which returns the sum of all the values in the specified column. SUM works on numeric fields only. Null values are excluded from the result returned.
4.AVG function
MySQL AVG function returns the average of the values in a specified column. Just like the SUM function, it works only on numeric data types.
5.MIN function
The MIN function returns the smallest value in the specified table field.
Forget everything you know about Template Haskell. We will enter the beautiful world of Typed Template Haskell where its only possible to construct well-scoped and well-typed terms. Why? By writing our program in multiple stages, we can guarantee to eliminate the interpretative overhead caused by abstraction.
Matthew will give an introduction to Typed Template Haskell and then describe some examples of how to construct abstract and efficient programs using techniques from multi-stage programming. We will construct an "efficient" power function and also give a sketch of how to implement a SQL query compiler as inspired by the functional pearl "A SQL to C Compiler in 500 Lines of Code".
Matthew is a PhD student at the University of Bristol focusing on program generation with applications to optimisation. In the quest to write the perfect program he has become a regular contributor to GHC where he has recently been working on making the compiler easier to extend by using source plugins.
The symbols which are used to perform logical and mathematical operations in a C program are called C operators. These C operators join individual constants and variables to form expressions. Operators, functions, constants and variables are combined together to form expressions. Consider the expression A + B * 5.
Operators and expressions in c languagetanmaymodi4
what is operator in c language
uses of operator in c language
syatax of operator in c language
program of operator in c language
what is expressions in c language
use of expressions in c language
syantax of expressions in c language
Aggregate functions are functions that take a collection of values as input and return a single value.The ISO standard defines five (5) aggregate functions namely :-
1) COUNT
2) SUM
3) AVG
4) MIN
5) MAX
1.COUNT Function
The COUNT function returns the total number of values in the specified field. It works on both numeric and non-numeric data types. All aggregate functions by default exclude nulls values before working on the data.
MIN function
The MIN function returns the smallest value in the specified table field.
2.MAX function
Just as the name suggests, the MAX function is the opposite of the MIN function. It returns the largest value from the specified table field.
3.SUM function
Suppose we want a report that gives total amount of payments made so far. We can use the MySQL SUM function which returns the sum of all the values in the specified column. SUM works on numeric fields only. Null values are excluded from the result returned.
4.AVG function
MySQL AVG function returns the average of the values in a specified column. Just like the SUM function, it works only on numeric data types.
5.MIN function
The MIN function returns the smallest value in the specified table field.
Forget everything you know about Template Haskell. We will enter the beautiful world of Typed Template Haskell where its only possible to construct well-scoped and well-typed terms. Why? By writing our program in multiple stages, we can guarantee to eliminate the interpretative overhead caused by abstraction.
Matthew will give an introduction to Typed Template Haskell and then describe some examples of how to construct abstract and efficient programs using techniques from multi-stage programming. We will construct an "efficient" power function and also give a sketch of how to implement a SQL query compiler as inspired by the functional pearl "A SQL to C Compiler in 500 Lines of Code".
Matthew is a PhD student at the University of Bristol focusing on program generation with applications to optimisation. In the quest to write the perfect program he has become a regular contributor to GHC where he has recently been working on making the compiler easier to extend by using source plugins.
The symbols which are used to perform logical and mathematical operations in a C program are called C operators. These C operators join individual constants and variables to form expressions. Operators, functions, constants and variables are combined together to form expressions. Consider the expression A + B * 5.
Operators and expressions in c languagetanmaymodi4
what is operator in c language
uses of operator in c language
syatax of operator in c language
program of operator in c language
what is expressions in c language
use of expressions in c language
syantax of expressions in c language
The expression evaluation is compiler dependent, and may vary. A g.pdfsharnapiyush773
The expression evaluation is compiler dependent, and may vary.
A general rule is still followed by many compilers, the rule of precedence and associativity,
which is as follows:
Symbol1
Type of Operation
Associativity
[ ] ( ) . –> postfix ++ and postfix ––
Expression
Left to right
prefix ++ and prefix ––sizeof & * + – ~ !
Unary
Right to left
typecasts
Unary
Right to left
* / %
Multiplicative
Left to right
+ –
Additive
Left to right
<< >>
Bitwise shift
Left to right
< > <= >=
Relational
Left to right
== !=
Equality
Left to right
&
Bitwise-AND
Left to right
^
Bitwise-exclusive-OR
Left to right
|
Bitwise-inclusive-OR
Left to right
&&
Logical-AND
Left to right
||
Logical-OR
Left to right
? :
Conditional-expression
Right to left
= *= /= %=
+= –= <<= >>=&=
^= |=
Simple and compound assignment2
Right to left
,
Sequential evaluation
Left to right
As per the above table the expression (5+11)/(16-100) will be evaluated as
5+11 = 16 then 16-100 = -84 and then 16 / -84 = -0.190476
but if you look at the output in a program it will show it as 0 since it will take the int value.
to see the float value you can use this expression (5.0+11.0)/(16.0-100.0) i.e. just add .0
(decimal 0 to convert it to a float).
Q2. 65-78+90*4
90*4=360 is evaluated first due to high precedance
now, expression becomes 65-78+360 and + and - have the same precedance and the expression
is evaluated from left to right
65-78 = -13
now -13+360 = 347
Q3. 10%2/91*(4-12)
first braces (4-12) = -8
10 % 2 / 91 * -8 now all operators here have the same precedence, and they will be evaluated
from left to right
so, 10%2 = 0
now, the exp. is 0 / 91 * -8
0/91 = 0
now, the exp. is 0 * -8 = 0
2.) the backslash (\\) is used as escape sequence in C/C++, escape sequences when used in
strings represent a different character, to print the given string we need to print the \\ character
itself which is represented by a double backslash i.e. \\\\.
printf(\"The backslash (\\\\) is used in a folder path.\ Don\'t use more than two together.\");
Symbol1
Type of Operation
Associativity
[ ] ( ) . –> postfix ++ and postfix ––
Expression
Left to right
prefix ++ and prefix ––sizeof & * + – ~ !
Unary
Right to left
typecasts
Unary
Right to left
* / %
Multiplicative
Left to right
+ –
Additive
Left to right
<< >>
Bitwise shift
Left to right
< > <= >=
Relational
Left to right
== !=
Equality
Left to right
&
Bitwise-AND
Left to right
^
Bitwise-exclusive-OR
Left to right
|
Bitwise-inclusive-OR
Left to right
&&
Logical-AND
Left to right
||
Logical-OR
Left to right
? :
Conditional-expression
Right to left
= *= /= %=
+= –= <<= >>=&=
^= |=
Simple and compound assignment2
Right to left
,
Sequential evaluation
Left to right
Solution
The expression evaluation is compiler dependent, and may vary.
A general rule is still followed by many compilers, the rule of precedence and associativity,
which is as follows:
Symbol1
Type of Operation
Associativity
[ ] ( ) . –> postfix ++ and postfix ––
Expression
Left to right
prefix ++ and prefi.
Operators in C and C++ Programming Language:
Operators are the symbols which tells the language compiler to perform a specific mathematical or logical function. C and C++ programming is very rich in Operators. C and C++ Language Provides the following type of Operator:-
1. Arithmetic Operators
2. Relational Operators
3. Logical Operators
4. Bitwise Operators
5. Assignment Operators
6. Misc Operators
You will Study all these operators with these Slides. Hope you will find it helpful. If you find it helpful then please Let others know by Like and Sharing. If you don't like so please let us know. So that i can make it more better.
If you have to ask anything about any operator then you can ask in comments.
Thankyou for visit
Sahyog Vishwakarma
2. Precedence and Associativity of Operators
Operators Associativity
( ) [ ] . -> ++(postfix) --(postfix) left to right
++(prefix) --(prefix) ! ~ sizeof(type)
right to left
+(unary) -(unary) &(address) *(dereference)
* / % left to right
+ - left to right
<< >> left to right
< <= > >= left to right
== != left to right
& left to right
^ left to right
| left to right
&& left to right
|| left to right
? : right to left
= += -= *= /= %= >>= <<= &= ^= |= right to left
2
3. Operators
Comparison:
C operator Description Example
== = a == 2
!= Not equal a != 3
< < a<3
> > a>4
<= a <= 5
>= a >= 3
! Negative !(a < 3)
&& and (3 < a) && (a < 5)
|| or (a < 3) || ( 5 < a)
3
5. Operators
Assignment
Operator Description Example
= assignment a=b
+= a=a+3 a += 3
-= a=a-3 a -= 3
*= a=a*3 a *= 3
/= a=a/3 a /= 3
%= a=a%3 a %= 3
5
6. Increment and Decrement Operators
Increment operator
Postfix k++
k = k - 1 ;
Prefix ++k
Decrement operator
Postfix k--
k = k - 1 ;
Prefix --k
But, It is a different when use with another operator
Prefix : increase or decrease before used in expression
Postfix : increase or decrease after used in expression
6
7. Increment and Decrement Operators
[Ex] int i = 4, j;
j = ++i + 3;
printf(“i : %d, j = %dn”, i, j);
j = i++ + 3;
printf(“i : %d, j = %dn”, i, j);
j = --i + 3;
printf(“i : %d, j = %dn”, i, j);
j = i-- + 3;
printf(“i : %d, j = %dn”, i, j);
i = 5, j =8
i = 6, j =8
i = 5, j =8
i = 4, j =8
7
8. Bit Operators
<<, >>, |, &, ^,~
– << : Left shift n places
a = 100 << 1 ; 100 -> 01100100
printf( “%d”, a ) Shift to left by 1 bit
11001000 (=200)
– >> : Right shift n places
a = 100 >> 1 ; 100 -> 01100100
printf( “%d”, a ) Shift to right by 1 bit
001100100 (=50)
8
9. Bit Operators
(8bit Computer)
<<, >>, |, &, ^,~
– | : Logical OR, if either bit is 1, 100 -> 01100100
the result is 1 200 -> 11001000
a = 100 | 200 ; -------------------
printf( “%d”, a ) a = 11101100 (236)
– & : Logical AND, if both bits are 1,
100 -> 01100100
the result is 1
200 -> 11001000
a = 100 & 200 ; -------------------
printf( “%d”, a ) a = 01000000 (64)
– ^ : Logical XOR, if one and only
one bit is 1, the result is 1 100 -> 01100100
a = 100 ^ 200 ; 200 -> 11001000
printf( “%d”, a ) -------------------
a = 10101100 (172)
9
10. Bit Operators
(8bit Computer)
<<, >>, |, &, ^,~
– ~ : Logical inverter 100 -> 01100100
-------------------
a = ~100;
a = 10011011 (155)
printf( “%d”, a )
10
11. Example
[Ex]
i = 3 , j = 2 , k = 1 ;
if ( i > j > k ) printf( “Yes” )
else printf( “No” ) ;
[Ex]
int a, i =1, j = 2, k ;
a = i < 2 + j;
j = 5 * (k = 3);
printf( “%d %d %dn”, a, i, j, k ) ;
( i < j ) && ( j < k )
This statement means that j is between i and k.
11
12. Example
Example
int a = 5, b = 6, c = 7 ;
int d ;
printf( “%d %d %dn, a < b, a > b, a != b ) ;
d = (a < b) && (b < c ) ;
printf( “%d %d %dn”, d, (a > b) || (b > c), !(!5) ) ;
12
13. Assignment Operators
Compound Assignment
– Compound Assignment operators
op= [Ex] *=, -=, /=, %=, +=
– variable = variable op (expression)
=> variable op= expression
[Ex] int k = 5;
k += 2; /* k = k + 2, k=7 */
k -= 2; /* k = k - 2, k=5 */
k *= 2; /* k = k * 2, k=10 */
k /= 2; /* k = k / 2, k=5 */
k %= 2; /* k = k % 2, k=1 */
13