Operators and Expressions in C Programming, Slides of C programming

Explanation in details about operators and expressions in C Programming

Typology: Slides

2025/2026

Available from 06/08/2026

rakib-chowdhury
rakib-chowdhury 🇧🇩

5 documents

1 / 22

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16

Partial preview of the text

Download Operators and Expressions in C Programming and more Slides C programming in PDF only on Docsity!

Definition “An operator is a symbol (+,-,*,/) that directs the computer to perform certain mathematical or logical manipulations and is usually used to manipulate data and variables” Ex: a+b

Arithmetic operators

Operator example Meaning

  • a + b Addition
  • a – b Subtraction
  • a * b Multiplication / a / b Division % a % b Modulo division- remainder

Relational Operators

Operator Meaning < Is less than <= Is less than or equal to > Is greater than >= Is greater than or equal to == Equal to != Not equal to

Truth Table

a b Value of the expression a && b a || b 0 0 0 0 0 1 0 1 1 0 0 1 (^1 1 1 )

Assignment operators

Syntax: v op = exp; Where v = variable, op = shorthand assignment operator exp = expression Ex: x=x+ x+=

Increment & Decrement Operators

C supports 2 useful operators namely

  1. Increment ++
  2. Decrement – operators The ++ operator adds a value 1 to the operand The – operator subtracts 1 from the operand ++a or a++ --a or a--

Rules for ++ & -- operators

  1. These require variables as their operands
  2. When postfix either ++ or – is used with the variable in a given expression, the expression is evaluated first and then it is incremented or decremented by one
  3. When prefix either ++ or – is used with the variable in a given expression, it is incremented or decremented by one first and then the expression is evaluated with the new value

Conditional operators

Syntax: exp1? exp2 : exp Where exp1,exp2 and exp3 are expressions Working of the? Operator: Exp1 is evaluated first, if it is nonzero(1/true) then the expression2 is evaluated and this becomes the value of the expression, If exp1 is false(0/zero) exp3 is evaluated and its value becomes the value of the expression Ex: m=2; n= r=(m>n)? m : n;

Bitwise operators

These operators allow manipulation of data at the bit level Operator Meaning & Bitwise AND | Bitwise OR ^ Bitwise exclusive OR << Shift left >> Shift right

Arithmetic Expressions

Algebraic expression C expression axb-c ab-c (m+n)(x+y) (m+n)(x+y) ab/c 3x 2 +2x+1 3xx+2x+ a/b S=(a+b+c)/ c ab b a 2 abc S=

Arithmetic Expressions

Algebraic expression C expression area= area=sqrt(s(s-a)(s-b)(s-c)) sin(b/sqrt(aa+bb)) tow1=sqrt((rowx-rowy)/2+towxyy) tow 1 =sqrt(pow((rowx-rowy)/2,2)+towxyy) y=(alpha+beta)/sin(theta3.1416/180)+abs(x)** s ( sa )( sb )( sc ) Sin          2 2 a b b 2 1 2 xy x y              2 2 1 2 xy x y              yx      sin

Rules for evaluation of expression

  1. First parenthesized sub expression from left to right are evaluated.
  2. If parentheses are nested, the evaluation begins with the innermost sub expression
  3. The precedence rule is applied in determining the order of application of operators in evaluating sub expressions
  4. The associatively rule is applied when 2 or more operators of the same precedence level appear in a sub expression.
  5. Arithmetic expressions are evaluated from left to right using the rules of precedence
  6. When parentheses are used, the expressions within parentheses assume highest priority

Hierarchy of operators

Operator Description Associativity ( ), [ ] Function call, array element reference Left to Right +, - , ++, - - ,!,~,*,& Unary plus, minus, increment, decrement, logical negation, 1’s complement, pointer reference, address Right to Left *, / , % Multiplication, division, modulus Left to Right