SlideShare ist ein Scribd-Unternehmen logo
1 von 37
Downloaden Sie, um offline zu lesen
Operators and Expressions

       www.eshikshak.co.in
Introduction
• An operator indicates an operation to be
  performed on data that yields a new value.
• An operand is a data items on which operators
  perform operations.
• C provides rich set of “Operators”
  – Arithmetic
  – Relational
  – Logical
  – Bitwise

                    www.eshikshak.co.in
Introduction




   www.eshikshak.co.in
Properties of Operators
• Precedence
  – Precedence means priority.
  – When an expressions contains many operators,
    the operations are carried out according to the
    priority of the operators.
  – The higher priority operations are solved first.
  – Example
     • 10 * 5 + 4 / 2
     • 10 + 5 – 8 * 2 / 2

                            www.eshikshak.co.in
Properties of Operators
•   Associativity
     – Associativity means the direction of execution.
     – When an expression has operators with same precedence, the associativity
        property decides which operation to be carried out first.
     a) Left to Right : The expression evaluation starts from the left to right direction
               Example : 12 * 4 / 8 % 2
                             48 / 8 % 2
                                  6%2
                                  0
     b) Right to Left : The expression evaluation starts from right to left direction
              Example : X = 8 + 5 % 2
                         X=8+1
                 X=9




                                      www.eshikshak.co.in
Priority of Operators and their clubbing

• Each and every operator in C having its
  priority and precedence fixed on the basis of
  these property expression is solved.
• Operators from the same group may have
  different precedence and associativity.
• If arithmetic expression contains more
  operators, the execution will be performed
  according to their priorities.

                    www.eshikshak.co.in
Priority of Operators and their clubbing

• When two operators of the same priority are
  found in the expression, the precedence is
  given from the left most operators.
  x=5*4+8/2                                (8 / ( 2 * ( 2 * 2 ) ) )
                  2                                                    1
      1

                                                                   2
            3


                                                              3


                      www.eshikshak.co.in
Comma and Conditional Operator
• It is used to separate two                 void main()
  or more expressions.                       {
• It has lowest precedence
                                                clrscr();
  among all the operators
• It is not essential to                       printf(“%d %d”, 2+3, 3-2);
  enclose the expressions                    }
  with comma operators
  within the parenthesis.
                                            OUTPUT :
• Following statements are
  valid                                     5 1
    a = 2, b = 4, c = a + b;
    ( a=2, b = 4, c = a + b );

                             www.eshikshak.co.in
Conditional Operator (?:)
• This operator contains condition followed by
  two statements and values.
• It is also called as ternary operator.
• Syntax :
  Condition ? (expression1) : (expression2);
• If the condition is true, than expression1 is
  executed, otherwise expression2 is executed


                      www.eshikshak.co.in
Conditional Operator (?:)
• Example :
     void main()
     {
          clrscr();
          printf(“Maximum : %d”, 5>3 ? 5 : 3)
     }
OUTPUT :
  Maximum : 5

                   www.eshikshak.co.in
Conditional Operator (?:)
• Example :
     void main()
     {
          clrscr();
          printf(“Maximum : %d”, 5>3 ? 5 : 3)
     }
OUTPUT :
  Maximum : 5

                   www.eshikshak.co.in
Conditional Operator (?:)
• Example :
     void main()
     {
           clrscr();
           5 > 3 ? printf(“True”) : printf(“False”);
           printf(“%d is ”, 5>3 ? : 3)
     }
OUTPUT :
  Maximum : 5
                      www.eshikshak.co.in
Arithmetic Operator
• Two types of arithmetic operators
  – Binary Operator
  – Unary Operator
                      Operators


     Unary              Binary              Ternary




                      www.eshikshak.co.in
Arithmetic Operator
• Binary Operator
   – An operator which requires two operator is know
     as binary operator
   – List of Binary Operators
Arithmetic Operator   Operator Explanation              Examples
        +                   Addition                    2+2=4
         -                Subtraction                   5–3=2
        *                Multiplication                 2 * 5 = 10
         /                  Division                    10 / 2 = 5
        %               Modular Division         11 % 3 = 2 (Remainder 2)


                           www.eshikshak.co.in
Arithmetic Operator
• Unary Operator
  – The operator which requires only one operand is
    called unary operator
  – List of unary operator are
    Operator      Description or Action
    -             Minus
    ++            Increment
    --            Decrement
    &             Address Operator
    Sizeof        Gives the size of the operator

                           www.eshikshak.co.in
Unary Operator - Minus
• Unary minus is used for indicating or changing
  the algebraic sign of a value
• Example
    int x = -50;
    int y = -x;
• There is no unary plus (+) in C. Even though a
  value assigned with plus sign is valid.


                    www.eshikshak.co.in
Increment (++) and Decrement (--)
              Operator
• The ++ operator adds value one to its
  operand.
• X = X + 1 can be written as X++;
• There are two types ++ increment operator
  base on the position are used with the
  operand.



                   www.eshikshak.co.in
Pre-increment (i.e. ++x)
int x =5, y;
y = ++x;
printf(“x = %dn y = %d”, ++x, y);

OUTPUT :                                   x = x + 1;

x=7                 y = ++x;
y=6                                        y = x;


                     www.eshikshak.co.in
Post-increment (i.e. ++x)
int x =5, y;
y = x++;
printf(“x = %dn y = %d”, x++, y);

OUTPUT :                                   y = x;

x=7                 y = x++;
y=6                                        x = x + 1;


                     www.eshikshak.co.in
Pre-decrement (i.e. --x)
int x =5, y;
y = --x;
printf(“x = %dn y = %d”, --x, y);

OUTPUT :                                   x = x - 1;

x=3                 y = --x;
y=4                                        y = x;


                     www.eshikshak.co.in
Post-decrement (i.e. ++x)
int x =5, y;
y = x--;
printf(“x = %dn y = %d”, x--, y);

OUTPUT :                                   y = x;

x=7                 y = x--;
y=6                                        x = x - 1;


                     www.eshikshak.co.in
sizeof operator
• The sizeof operator           void main()
  gives the bytes               {
  occupied by a variable.          int x = 12;
• i.e. the size in terms of       float y = 2;
  bytes required in                printf(“size of x : %d”, sizeof(x));
                                  printf(“nsize of y :%d”, sizeof(y));
  memory to store the
  value.                        }

• The number of bytes           OUTPUT :
  occupied varies from          sizeof x : 2
  variable to variable          sizeof y : 4
  depending upon its
  data type.
                         www.eshikshak.co.in
‘&’ Operator
• The ‘&’ returns the address of the variable in a
  memory.

  Address
                                        int x = 15
                2040
                                        printf(“%d”,x);
    Value
                 15
   Variable      X
                                        printf(“n%u”,&x);



                       www.eshikshak.co.in
Relational Operator
• These operators are used to distinguish
  two values depending on their relations.
• These operators provide the relationship
  between two expressions.
• If the relation is true it returns a value 1
  otherwise 0 for false.


                   www.eshikshak.co.in
Relational Operator
Operator    Description or Action              Example Return Value
   >            Greater than                    5>4          1
   <              Less than                    10 < 9        0
  <=        Less than or equal to              10 <= 10      1

  >=       Greater than or equal to            11 >= 5       1
  ==              Equal to                      2 == 3       0
   !=           Not Equal to                    3 != 3       0


                         www.eshikshak.co.in
Assignment Operator
• Assigning a value to a variable is very sample.
  int x = 5

                      Assignment Operator
          =             *=                          /=    %=
         +=              -=                         <<=   >>=
        >>>=            &=                          ^=    !=

int x = 10;
printf(“x = %dn”,x += 5); // x = x + 5; O/P x = 15

                              www.eshikshak.co.in
Logical Operators
• The logical operator between the two
  expressions is tested with logical operators.
• Using these operators, two expressions can be
  joined.
• After checking the conditions, it provides
  logical true(1) or false(0) status.
• The operands could be constants, variables
  and expressions.

                   www.eshikshak.co.in
Logical Operators
Operator   Description or Action            Example       Return Value
   &&          Logical AND             5 > 3 && 5 < 10         1
   ||           Logical OR               8 > 5 || 8 < 2        1
    !          Logical NOT                    8 != 8           0


i. The logical AND (&&) operator provides true result
     when both expressions are true otherwise 0.
ii. The logical OR (||) operator true result when one of
     the expressions is true otherwise 0.
iii. The logical NOT (!) provides 0 if the condition is true
     otherwise 1.

                             www.eshikshak.co.in
Bitwise Operator
• C supports a set of bitwise operators for bit
  manipulation

       Operators   Meaning
       >>          Right Shift
       <<          Left Shift
       ^           Bitwise XOR (exclusive OR)
       ~           One’s Complement
       &           Bitwise AND
       |           Bitwise |



                          www.eshikshak.co.in
void main() two bits means the inputted number is to be divided by 2 s where
  Shifting of
{ s is the number of shifts i.e. in short y = n/2s
    int x, y;
  Where n = number and s = the number of position to be shift.
     clrscr();
  For example as Thethe program keyword (x) ;
     print(“Read per Integer from
     scanf(“%d”, &x); // input value for x = 8
    Y = 8 / 22 = 2
            2




      x>>2;
      y=x;
     printf(“The Right shifted data is = %d”, y);




                                  www.eshikshak.co.in
}
void main() three bits left means the number is multiplied by 8; in short
  Shifting of
{ y = n * 2s
  where n = number
   int x, y;
          s = the number of position to be shifted
    clrscr();
  Asprint(“Read The Integer from keyword (x) ;
     per the program
    scanf(“%d”, &x); // input value for x = 2
    Y=2*2  3




     x<<=3;
     y=x;
    printf(“The Right shifted data is = %d”, y);




                                  www.eshikshak.co.in
}
void main()
{
    int a, b, c;
    clrscr();
     printf(“Read the integers from keyboard ( a & b ) :”);
     scanf(“%d %d”, &a, &b);
     c = a & b;
     printf(“The answer after ANDing is (C) = %d”, c);
}

OUTPUT :
Read the Integers from keyboard (a & b) : 8 4
The Answer after ANDing is (C) = 0

                           www.eshikshak.co.in
Table of exclusive AND
X         Y                         Outputs

0         0                         0

0         1                         0

1         0                         0

1         1                         1




              www.eshikshak.co.in
Binary equivalent of 8




Binary equivalent of 4




After execution
C=0
Binary equivalent of 0




                         www.eshikshak.co.in
void main()
{
    int a, b, c;
    clrscr();
     printf(“Read the integers from keyboard ( a & b ) :”);
     scanf(“%d %d”, &a, &b);
     c = a | b;
     printf(“The answer after ORing is (C) = %d”, c);
}

OUTPUT :
Read the Integers from keyboard (a & b) : 8 4
The Answer after ORing is (C) = 12

                           www.eshikshak.co.in
Table of exclusive OR
X         Y                         Outputs

0         0                         0

0         1                         1

1         0                         1

1         1                         0




              www.eshikshak.co.in
Binary equivalent of 8




Binary equivalent of 4




After execution
C = 12
Binary equivalent of 0




                         www.eshikshak.co.in

Weitere ähnliche Inhalte

Was ist angesagt?

Lesson 4 division of a line segment
Lesson 4   division of a line segmentLesson 4   division of a line segment
Lesson 4 division of a line segmentJean Leano
 
Gaussian Quadrature Formula
Gaussian Quadrature FormulaGaussian Quadrature Formula
Gaussian Quadrature FormulaDhaval Shukla
 
Function transformations
Function transformationsFunction transformations
Function transformationsTerry Gastauer
 
Avo ppt (Amplitude Variation with Offset)
Avo ppt (Amplitude Variation with Offset)Avo ppt (Amplitude Variation with Offset)
Avo ppt (Amplitude Variation with Offset)Haseeb Ahmed
 
Rational functions
Rational functionsRational functions
Rational functionszozima
 
Formal Logic - Lesson 4 - Tautology, Contradiction and Contingency
Formal Logic - Lesson 4 - Tautology, Contradiction and ContingencyFormal Logic - Lesson 4 - Tautology, Contradiction and Contingency
Formal Logic - Lesson 4 - Tautology, Contradiction and ContingencyLaguna State Polytechnic University
 
Basic geostatistics
Basic geostatisticsBasic geostatistics
Basic geostatisticsSerdar Kaya
 
Petrel 2014 Presentation- Your Guide For Exploring Petrel 2014
Petrel  2014 Presentation- Your Guide For Exploring Petrel 2014 Petrel  2014 Presentation- Your Guide For Exploring Petrel 2014
Petrel 2014 Presentation- Your Guide For Exploring Petrel 2014 Gamal Eldien Tarek
 

Was ist angesagt? (10)

Digital Electronics
Digital ElectronicsDigital Electronics
Digital Electronics
 
Lesson 4 division of a line segment
Lesson 4   division of a line segmentLesson 4   division of a line segment
Lesson 4 division of a line segment
 
weddle's rule
weddle's ruleweddle's rule
weddle's rule
 
Gaussian Quadrature Formula
Gaussian Quadrature FormulaGaussian Quadrature Formula
Gaussian Quadrature Formula
 
Function transformations
Function transformationsFunction transformations
Function transformations
 
Avo ppt (Amplitude Variation with Offset)
Avo ppt (Amplitude Variation with Offset)Avo ppt (Amplitude Variation with Offset)
Avo ppt (Amplitude Variation with Offset)
 
Rational functions
Rational functionsRational functions
Rational functions
 
Formal Logic - Lesson 4 - Tautology, Contradiction and Contingency
Formal Logic - Lesson 4 - Tautology, Contradiction and ContingencyFormal Logic - Lesson 4 - Tautology, Contradiction and Contingency
Formal Logic - Lesson 4 - Tautology, Contradiction and Contingency
 
Basic geostatistics
Basic geostatisticsBasic geostatistics
Basic geostatistics
 
Petrel 2014 Presentation- Your Guide For Exploring Petrel 2014
Petrel  2014 Presentation- Your Guide For Exploring Petrel 2014 Petrel  2014 Presentation- Your Guide For Exploring Petrel 2014
Petrel 2014 Presentation- Your Guide For Exploring Petrel 2014
 

Andere mochten auch

Mesics lecture 5 input – output in ‘c’
Mesics lecture 5   input – output in ‘c’Mesics lecture 5   input – output in ‘c’
Mesics lecture 5 input – output in ‘c’eShikshak
 
Operator Precedence and Associativity
Operator Precedence and AssociativityOperator Precedence and Associativity
Operator Precedence and AssociativityNicole Ynne Estabillo
 
Html phrase tags
Html phrase tagsHtml phrase tags
Html phrase tagseShikshak
 
Lecture21 categoriesof userdefinedfunctions.ppt
Lecture21 categoriesof userdefinedfunctions.pptLecture21 categoriesof userdefinedfunctions.ppt
Lecture21 categoriesof userdefinedfunctions.ppteShikshak
 
Mesics lecture 5 input – output in ‘c’
Mesics lecture 5   input – output in ‘c’Mesics lecture 5   input – output in ‘c’
Mesics lecture 5 input – output in ‘c’eShikshak
 
Lecture15 comparisonoftheloopcontrolstructures.ppt
Lecture15 comparisonoftheloopcontrolstructures.pptLecture15 comparisonoftheloopcontrolstructures.ppt
Lecture15 comparisonoftheloopcontrolstructures.ppteShikshak
 
Mesics lecture 3 c – constants and variables
Mesics lecture 3   c – constants and variablesMesics lecture 3   c – constants and variables
Mesics lecture 3 c – constants and variableseShikshak
 
Lecture 7 relational_and_logical_operators
Lecture 7 relational_and_logical_operatorsLecture 7 relational_and_logical_operators
Lecture 7 relational_and_logical_operatorseShikshak
 
Lecture7relationalandlogicaloperators 110823181038-phpapp02
Lecture7relationalandlogicaloperators 110823181038-phpapp02Lecture7relationalandlogicaloperators 110823181038-phpapp02
Lecture7relationalandlogicaloperators 110823181038-phpapp02eShikshak
 
Automotive Circuit Boards
Automotive Circuit BoardsAutomotive Circuit Boards
Automotive Circuit BoardsArt Wood
 
C presentation book
C presentation bookC presentation book
C presentation bookkrunal1210
 
Programming embedded system_ii_keil_8051(1)
Programming embedded system_ii_keil_8051(1)Programming embedded system_ii_keil_8051(1)
Programming embedded system_ii_keil_8051(1)Fendie Mimpi
 
RoHS Compliant Lead Free PCB Fabrication
RoHS Compliant Lead Free PCB FabricationRoHS Compliant Lead Free PCB Fabrication
RoHS Compliant Lead Free PCB FabricationArt Wood
 
Mesics lecture files in 'c'
Mesics lecture   files in 'c'Mesics lecture   files in 'c'
Mesics lecture files in 'c'eShikshak
 
Unit 1.3 types of cloud
Unit 1.3 types of cloudUnit 1.3 types of cloud
Unit 1.3 types of cloudeShikshak
 
Mesics lecture 8 arrays in 'c'
Mesics lecture 8   arrays in 'c'Mesics lecture 8   arrays in 'c'
Mesics lecture 8 arrays in 'c'eShikshak
 
Mesics lecture 7 iteration and repetitive executions
Mesics lecture 7   iteration and repetitive executionsMesics lecture 7   iteration and repetitive executions
Mesics lecture 7 iteration and repetitive executionseShikshak
 
Unit 1.1 introduction to cloud computing
Unit 1.1   introduction to cloud computingUnit 1.1   introduction to cloud computing
Unit 1.1 introduction to cloud computingeShikshak
 

Andere mochten auch (20)

Mesics lecture 5 input – output in ‘c’
Mesics lecture 5   input – output in ‘c’Mesics lecture 5   input – output in ‘c’
Mesics lecture 5 input – output in ‘c’
 
Operator Precedence and Associativity
Operator Precedence and AssociativityOperator Precedence and Associativity
Operator Precedence and Associativity
 
Html phrase tags
Html phrase tagsHtml phrase tags
Html phrase tags
 
Lecture21 categoriesof userdefinedfunctions.ppt
Lecture21 categoriesof userdefinedfunctions.pptLecture21 categoriesof userdefinedfunctions.ppt
Lecture21 categoriesof userdefinedfunctions.ppt
 
Mesics lecture 5 input – output in ‘c’
Mesics lecture 5   input – output in ‘c’Mesics lecture 5   input – output in ‘c’
Mesics lecture 5 input – output in ‘c’
 
Lecture15 comparisonoftheloopcontrolstructures.ppt
Lecture15 comparisonoftheloopcontrolstructures.pptLecture15 comparisonoftheloopcontrolstructures.ppt
Lecture15 comparisonoftheloopcontrolstructures.ppt
 
Mesics lecture 3 c – constants and variables
Mesics lecture 3   c – constants and variablesMesics lecture 3   c – constants and variables
Mesics lecture 3 c – constants and variables
 
Lecture 7 relational_and_logical_operators
Lecture 7 relational_and_logical_operatorsLecture 7 relational_and_logical_operators
Lecture 7 relational_and_logical_operators
 
Lecture7relationalandlogicaloperators 110823181038-phpapp02
Lecture7relationalandlogicaloperators 110823181038-phpapp02Lecture7relationalandlogicaloperators 110823181038-phpapp02
Lecture7relationalandlogicaloperators 110823181038-phpapp02
 
Automotive Circuit Boards
Automotive Circuit BoardsAutomotive Circuit Boards
Automotive Circuit Boards
 
C presentation book
C presentation bookC presentation book
C presentation book
 
Programming embedded system_ii_keil_8051(1)
Programming embedded system_ii_keil_8051(1)Programming embedded system_ii_keil_8051(1)
Programming embedded system_ii_keil_8051(1)
 
RoHS Compliant Lead Free PCB Fabrication
RoHS Compliant Lead Free PCB FabricationRoHS Compliant Lead Free PCB Fabrication
RoHS Compliant Lead Free PCB Fabrication
 
Mesics lecture files in 'c'
Mesics lecture   files in 'c'Mesics lecture   files in 'c'
Mesics lecture files in 'c'
 
Algorithm
AlgorithmAlgorithm
Algorithm
 
Unit 1.3 types of cloud
Unit 1.3 types of cloudUnit 1.3 types of cloud
Unit 1.3 types of cloud
 
Mesics lecture 8 arrays in 'c'
Mesics lecture 8   arrays in 'c'Mesics lecture 8   arrays in 'c'
Mesics lecture 8 arrays in 'c'
 
Mesics lecture 7 iteration and repetitive executions
Mesics lecture 7   iteration and repetitive executionsMesics lecture 7   iteration and repetitive executions
Mesics lecture 7 iteration and repetitive executions
 
Unit 1.1 introduction to cloud computing
Unit 1.1   introduction to cloud computingUnit 1.1   introduction to cloud computing
Unit 1.1 introduction to cloud computing
 
SMT machine Training Manual for FUJI CP6 Series Level 3
SMT machine Training Manual for FUJI  CP6 Series Level 3SMT machine Training Manual for FUJI  CP6 Series Level 3
SMT machine Training Manual for FUJI CP6 Series Level 3
 

Ähnlich wie Mesics lecture 4 c operators and experssions

Operators and expressions in C++
Operators and expressions in C++Operators and expressions in C++
Operators and expressions in C++Neeru Mittal
 
Operators inc c language
Operators inc c languageOperators inc c language
Operators inc c languageTanmay Modi
 
Operators and expressions in c language
Operators and expressions in c languageOperators and expressions in c language
Operators and expressions in c languagetanmaymodi4
 
Java script questions
Java script questionsJava script questions
Java script questionsSrikanth
 
Operators in java script
Operators   in  java scriptOperators   in  java script
Operators in java scriptAbhinav Somani
 
Operators in c language
Operators in c languageOperators in c language
Operators in c languageAmit Singh
 
Chapter 3.3
Chapter 3.3Chapter 3.3
Chapter 3.3sotlsoc
 
Class_IX_Operators.pptx
Class_IX_Operators.pptxClass_IX_Operators.pptx
Class_IX_Operators.pptxrinkugupta37
 
Functional Operations - Susan Potter
Functional Operations - Susan PotterFunctional Operations - Susan Potter
Functional Operations - Susan Potterdistributed matters
 
c++ Data Types and Selection
c++ Data Types and Selectionc++ Data Types and Selection
c++ Data Types and SelectionAhmed Nobi
 
Basic_C++ Notes with problema from Preethi arora and suneetha arora.pdf
Basic_C++ Notes with problema from Preethi arora and suneetha arora.pdfBasic_C++ Notes with problema from Preethi arora and suneetha arora.pdf
Basic_C++ Notes with problema from Preethi arora and suneetha arora.pdfComputer Programmer
 
Pi j1.3 operators
Pi j1.3 operatorsPi j1.3 operators
Pi j1.3 operatorsmcollison
 
FP 201 Unit 2 - Part 3
FP 201 Unit 2 - Part 3FP 201 Unit 2 - Part 3
FP 201 Unit 2 - Part 3rohassanie
 

Ähnlich wie Mesics lecture 4 c operators and experssions (20)

Operators and expressions in C++
Operators and expressions in C++Operators and expressions in C++
Operators and expressions in C++
 
Operators inc c language
Operators inc c languageOperators inc c language
Operators inc c language
 
Operators and expressions in c language
Operators and expressions in c languageOperators and expressions in c language
Operators and expressions in c language
 
Java script questions
Java script questionsJava script questions
Java script questions
 
Operators in java script
Operators   in  java scriptOperators   in  java script
Operators in java script
 
Operators
OperatorsOperators
Operators
 
Operators in C++
Operators in C++Operators in C++
Operators in C++
 
Operators in c language
Operators in c languageOperators in c language
Operators in c language
 
Chapter 3.3
Chapter 3.3Chapter 3.3
Chapter 3.3
 
C++ Tokens
C++ TokensC++ Tokens
C++ Tokens
 
Class_IX_Operators.pptx
Class_IX_Operators.pptxClass_IX_Operators.pptx
Class_IX_Operators.pptx
 
Functional Operations - Susan Potter
Functional Operations - Susan PotterFunctional Operations - Susan Potter
Functional Operations - Susan Potter
 
operators.ppt
operators.pptoperators.ppt
operators.ppt
 
Unit2wt
Unit2wtUnit2wt
Unit2wt
 
Unit2wt
Unit2wtUnit2wt
Unit2wt
 
c++ Data Types and Selection
c++ Data Types and Selectionc++ Data Types and Selection
c++ Data Types and Selection
 
Basic_C++ Notes with problema from Preethi arora and suneetha arora.pdf
Basic_C++ Notes with problema from Preethi arora and suneetha arora.pdfBasic_C++ Notes with problema from Preethi arora and suneetha arora.pdf
Basic_C++ Notes with problema from Preethi arora and suneetha arora.pdf
 
Pi j1.3 operators
Pi j1.3 operatorsPi j1.3 operators
Pi j1.3 operators
 
FP 201 Unit 2 - Part 3
FP 201 Unit 2 - Part 3FP 201 Unit 2 - Part 3
FP 201 Unit 2 - Part 3
 
What is c
What is cWhat is c
What is c
 

Mehr von eShikshak

Modelling and evaluation
Modelling and evaluationModelling and evaluation
Modelling and evaluationeShikshak
 
Operators in python
Operators in pythonOperators in python
Operators in pythoneShikshak
 
Datatypes in python
Datatypes in pythonDatatypes in python
Datatypes in pythoneShikshak
 
Introduction to python
Introduction to pythonIntroduction to python
Introduction to pythoneShikshak
 
Introduction to e commerce
Introduction to e commerceIntroduction to e commerce
Introduction to e commerceeShikshak
 
Chapeter 2 introduction to cloud computing
Chapeter 2   introduction to cloud computingChapeter 2   introduction to cloud computing
Chapeter 2 introduction to cloud computingeShikshak
 
Unit 1.4 working of cloud computing
Unit 1.4 working of cloud computingUnit 1.4 working of cloud computing
Unit 1.4 working of cloud computingeShikshak
 
Unit 1.2 move to cloud computing
Unit 1.2   move to cloud computingUnit 1.2   move to cloud computing
Unit 1.2 move to cloud computingeShikshak
 
Mesics lecture 6 control statement = if -else if__else
Mesics lecture 6   control statement = if -else if__elseMesics lecture 6   control statement = if -else if__else
Mesics lecture 6 control statement = if -else if__elseeShikshak
 
Lecture20 user definedfunctions.ppt
Lecture20 user definedfunctions.pptLecture20 user definedfunctions.ppt
Lecture20 user definedfunctions.ppteShikshak
 
Lecture18 structurein c.ppt
Lecture18 structurein c.pptLecture18 structurein c.ppt
Lecture18 structurein c.ppteShikshak
 
Lecture17 arrays.ppt
Lecture17 arrays.pptLecture17 arrays.ppt
Lecture17 arrays.ppteShikshak
 
Lecture13 control statementswitch.ppt
Lecture13 control statementswitch.pptLecture13 control statementswitch.ppt
Lecture13 control statementswitch.ppteShikshak
 
Lecturer23 pointersin c.ppt
Lecturer23 pointersin c.pptLecturer23 pointersin c.ppt
Lecturer23 pointersin c.ppteShikshak
 
Lecture19 unionsin c.ppt
Lecture19 unionsin c.pptLecture19 unionsin c.ppt
Lecture19 unionsin c.ppteShikshak
 
Program development cyle
Program development cyleProgram development cyle
Program development cyleeShikshak
 
Language processors
Language processorsLanguage processors
Language processorseShikshak
 
Computer programming programming_langugages
Computer programming programming_langugagesComputer programming programming_langugages
Computer programming programming_langugageseShikshak
 

Mehr von eShikshak (18)

Modelling and evaluation
Modelling and evaluationModelling and evaluation
Modelling and evaluation
 
Operators in python
Operators in pythonOperators in python
Operators in python
 
Datatypes in python
Datatypes in pythonDatatypes in python
Datatypes in python
 
Introduction to python
Introduction to pythonIntroduction to python
Introduction to python
 
Introduction to e commerce
Introduction to e commerceIntroduction to e commerce
Introduction to e commerce
 
Chapeter 2 introduction to cloud computing
Chapeter 2   introduction to cloud computingChapeter 2   introduction to cloud computing
Chapeter 2 introduction to cloud computing
 
Unit 1.4 working of cloud computing
Unit 1.4 working of cloud computingUnit 1.4 working of cloud computing
Unit 1.4 working of cloud computing
 
Unit 1.2 move to cloud computing
Unit 1.2   move to cloud computingUnit 1.2   move to cloud computing
Unit 1.2 move to cloud computing
 
Mesics lecture 6 control statement = if -else if__else
Mesics lecture 6   control statement = if -else if__elseMesics lecture 6   control statement = if -else if__else
Mesics lecture 6 control statement = if -else if__else
 
Lecture20 user definedfunctions.ppt
Lecture20 user definedfunctions.pptLecture20 user definedfunctions.ppt
Lecture20 user definedfunctions.ppt
 
Lecture18 structurein c.ppt
Lecture18 structurein c.pptLecture18 structurein c.ppt
Lecture18 structurein c.ppt
 
Lecture17 arrays.ppt
Lecture17 arrays.pptLecture17 arrays.ppt
Lecture17 arrays.ppt
 
Lecture13 control statementswitch.ppt
Lecture13 control statementswitch.pptLecture13 control statementswitch.ppt
Lecture13 control statementswitch.ppt
 
Lecturer23 pointersin c.ppt
Lecturer23 pointersin c.pptLecturer23 pointersin c.ppt
Lecturer23 pointersin c.ppt
 
Lecture19 unionsin c.ppt
Lecture19 unionsin c.pptLecture19 unionsin c.ppt
Lecture19 unionsin c.ppt
 
Program development cyle
Program development cyleProgram development cyle
Program development cyle
 
Language processors
Language processorsLanguage processors
Language processors
 
Computer programming programming_langugages
Computer programming programming_langugagesComputer programming programming_langugages
Computer programming programming_langugages
 

Kürzlich hochgeladen

WSMM Technology February.March Newsletter_vF.pdf
WSMM Technology February.March Newsletter_vF.pdfWSMM Technology February.March Newsletter_vF.pdf
WSMM Technology February.March Newsletter_vF.pdfJamesConcepcion7
 
NAB Show Exhibitor List 2024 - Exhibitors Data
NAB Show Exhibitor List 2024 - Exhibitors DataNAB Show Exhibitor List 2024 - Exhibitors Data
NAB Show Exhibitor List 2024 - Exhibitors DataExhibitors Data
 
Fordham -How effective decision-making is within the IT department - Analysis...
Fordham -How effective decision-making is within the IT department - Analysis...Fordham -How effective decision-making is within the IT department - Analysis...
Fordham -How effective decision-making is within the IT department - Analysis...Peter Ward
 
WSMM Media and Entertainment Feb_March_Final.pdf
WSMM Media and Entertainment Feb_March_Final.pdfWSMM Media and Entertainment Feb_March_Final.pdf
WSMM Media and Entertainment Feb_March_Final.pdfJamesConcepcion7
 
Environmental Impact Of Rotary Screw Compressors
Environmental Impact Of Rotary Screw CompressorsEnvironmental Impact Of Rotary Screw Compressors
Environmental Impact Of Rotary Screw Compressorselgieurope
 
Pitch Deck Teardown: Xpanceo's $40M Seed deck
Pitch Deck Teardown: Xpanceo's $40M Seed deckPitch Deck Teardown: Xpanceo's $40M Seed deck
Pitch Deck Teardown: Xpanceo's $40M Seed deckHajeJanKamps
 
14680-51-4.pdf Good quality CAS Good quality CAS
14680-51-4.pdf  Good  quality CAS Good  quality CAS14680-51-4.pdf  Good  quality CAS Good  quality CAS
14680-51-4.pdf Good quality CAS Good quality CAScathy664059
 
GUIDELINES ON USEFUL FORMS IN FREIGHT FORWARDING (F) Danny Diep Toh MBA.pdf
GUIDELINES ON USEFUL FORMS IN FREIGHT FORWARDING (F) Danny Diep Toh MBA.pdfGUIDELINES ON USEFUL FORMS IN FREIGHT FORWARDING (F) Danny Diep Toh MBA.pdf
GUIDELINES ON USEFUL FORMS IN FREIGHT FORWARDING (F) Danny Diep Toh MBA.pdfDanny Diep To
 
Healthcare Feb. & Mar. Healthcare Newsletter
Healthcare Feb. & Mar. Healthcare NewsletterHealthcare Feb. & Mar. Healthcare Newsletter
Healthcare Feb. & Mar. Healthcare NewsletterJamesConcepcion7
 
Intermediate Accounting, Volume 2, 13th Canadian Edition by Donald E. Kieso t...
Intermediate Accounting, Volume 2, 13th Canadian Edition by Donald E. Kieso t...Intermediate Accounting, Volume 2, 13th Canadian Edition by Donald E. Kieso t...
Intermediate Accounting, Volume 2, 13th Canadian Edition by Donald E. Kieso t...ssuserf63bd7
 
Memorándum de Entendimiento (MoU) entre Codelco y SQM
Memorándum de Entendimiento (MoU) entre Codelco y SQMMemorándum de Entendimiento (MoU) entre Codelco y SQM
Memorándum de Entendimiento (MoU) entre Codelco y SQMVoces Mineras
 
digital marketing , introduction of digital marketing
digital marketing , introduction of digital marketingdigital marketing , introduction of digital marketing
digital marketing , introduction of digital marketingrajputmeenakshi733
 
The-Ethical-issues-ghhhhhhhhjof-Byjus.pptx
The-Ethical-issues-ghhhhhhhhjof-Byjus.pptxThe-Ethical-issues-ghhhhhhhhjof-Byjus.pptx
The-Ethical-issues-ghhhhhhhhjof-Byjus.pptxmbikashkanyari
 
Welding Electrode Making Machine By Deccan Dynamics
Welding Electrode Making Machine By Deccan DynamicsWelding Electrode Making Machine By Deccan Dynamics
Welding Electrode Making Machine By Deccan DynamicsIndiaMART InterMESH Limited
 
20200128 Ethical by Design - Whitepaper.pdf
20200128 Ethical by Design - Whitepaper.pdf20200128 Ethical by Design - Whitepaper.pdf
20200128 Ethical by Design - Whitepaper.pdfChris Skinner
 
1911 Gold Corporate Presentation Apr 2024.pdf
1911 Gold Corporate Presentation Apr 2024.pdf1911 Gold Corporate Presentation Apr 2024.pdf
1911 Gold Corporate Presentation Apr 2024.pdfShaun Heinrichs
 
Traction part 2 - EOS Model JAX Bridges.
Traction part 2 - EOS Model JAX Bridges.Traction part 2 - EOS Model JAX Bridges.
Traction part 2 - EOS Model JAX Bridges.Anamaria Contreras
 
Interoperability and ecosystems: Assembling the industrial metaverse
Interoperability and ecosystems:  Assembling the industrial metaverseInteroperability and ecosystems:  Assembling the industrial metaverse
Interoperability and ecosystems: Assembling the industrial metaverseSiemens
 
Unveiling the Soundscape Music for Psychedelic Experiences
Unveiling the Soundscape Music for Psychedelic ExperiencesUnveiling the Soundscape Music for Psychedelic Experiences
Unveiling the Soundscape Music for Psychedelic ExperiencesDoe Paoro
 
Jewish Resources in the Family Resource Centre
Jewish Resources in the Family Resource CentreJewish Resources in the Family Resource Centre
Jewish Resources in the Family Resource CentreNZSG
 

Kürzlich hochgeladen (20)

WSMM Technology February.March Newsletter_vF.pdf
WSMM Technology February.March Newsletter_vF.pdfWSMM Technology February.March Newsletter_vF.pdf
WSMM Technology February.March Newsletter_vF.pdf
 
NAB Show Exhibitor List 2024 - Exhibitors Data
NAB Show Exhibitor List 2024 - Exhibitors DataNAB Show Exhibitor List 2024 - Exhibitors Data
NAB Show Exhibitor List 2024 - Exhibitors Data
 
Fordham -How effective decision-making is within the IT department - Analysis...
Fordham -How effective decision-making is within the IT department - Analysis...Fordham -How effective decision-making is within the IT department - Analysis...
Fordham -How effective decision-making is within the IT department - Analysis...
 
WSMM Media and Entertainment Feb_March_Final.pdf
WSMM Media and Entertainment Feb_March_Final.pdfWSMM Media and Entertainment Feb_March_Final.pdf
WSMM Media and Entertainment Feb_March_Final.pdf
 
Environmental Impact Of Rotary Screw Compressors
Environmental Impact Of Rotary Screw CompressorsEnvironmental Impact Of Rotary Screw Compressors
Environmental Impact Of Rotary Screw Compressors
 
Pitch Deck Teardown: Xpanceo's $40M Seed deck
Pitch Deck Teardown: Xpanceo's $40M Seed deckPitch Deck Teardown: Xpanceo's $40M Seed deck
Pitch Deck Teardown: Xpanceo's $40M Seed deck
 
14680-51-4.pdf Good quality CAS Good quality CAS
14680-51-4.pdf  Good  quality CAS Good  quality CAS14680-51-4.pdf  Good  quality CAS Good  quality CAS
14680-51-4.pdf Good quality CAS Good quality CAS
 
GUIDELINES ON USEFUL FORMS IN FREIGHT FORWARDING (F) Danny Diep Toh MBA.pdf
GUIDELINES ON USEFUL FORMS IN FREIGHT FORWARDING (F) Danny Diep Toh MBA.pdfGUIDELINES ON USEFUL FORMS IN FREIGHT FORWARDING (F) Danny Diep Toh MBA.pdf
GUIDELINES ON USEFUL FORMS IN FREIGHT FORWARDING (F) Danny Diep Toh MBA.pdf
 
Healthcare Feb. & Mar. Healthcare Newsletter
Healthcare Feb. & Mar. Healthcare NewsletterHealthcare Feb. & Mar. Healthcare Newsletter
Healthcare Feb. & Mar. Healthcare Newsletter
 
Intermediate Accounting, Volume 2, 13th Canadian Edition by Donald E. Kieso t...
Intermediate Accounting, Volume 2, 13th Canadian Edition by Donald E. Kieso t...Intermediate Accounting, Volume 2, 13th Canadian Edition by Donald E. Kieso t...
Intermediate Accounting, Volume 2, 13th Canadian Edition by Donald E. Kieso t...
 
Memorándum de Entendimiento (MoU) entre Codelco y SQM
Memorándum de Entendimiento (MoU) entre Codelco y SQMMemorándum de Entendimiento (MoU) entre Codelco y SQM
Memorándum de Entendimiento (MoU) entre Codelco y SQM
 
digital marketing , introduction of digital marketing
digital marketing , introduction of digital marketingdigital marketing , introduction of digital marketing
digital marketing , introduction of digital marketing
 
The-Ethical-issues-ghhhhhhhhjof-Byjus.pptx
The-Ethical-issues-ghhhhhhhhjof-Byjus.pptxThe-Ethical-issues-ghhhhhhhhjof-Byjus.pptx
The-Ethical-issues-ghhhhhhhhjof-Byjus.pptx
 
Welding Electrode Making Machine By Deccan Dynamics
Welding Electrode Making Machine By Deccan DynamicsWelding Electrode Making Machine By Deccan Dynamics
Welding Electrode Making Machine By Deccan Dynamics
 
20200128 Ethical by Design - Whitepaper.pdf
20200128 Ethical by Design - Whitepaper.pdf20200128 Ethical by Design - Whitepaper.pdf
20200128 Ethical by Design - Whitepaper.pdf
 
1911 Gold Corporate Presentation Apr 2024.pdf
1911 Gold Corporate Presentation Apr 2024.pdf1911 Gold Corporate Presentation Apr 2024.pdf
1911 Gold Corporate Presentation Apr 2024.pdf
 
Traction part 2 - EOS Model JAX Bridges.
Traction part 2 - EOS Model JAX Bridges.Traction part 2 - EOS Model JAX Bridges.
Traction part 2 - EOS Model JAX Bridges.
 
Interoperability and ecosystems: Assembling the industrial metaverse
Interoperability and ecosystems:  Assembling the industrial metaverseInteroperability and ecosystems:  Assembling the industrial metaverse
Interoperability and ecosystems: Assembling the industrial metaverse
 
Unveiling the Soundscape Music for Psychedelic Experiences
Unveiling the Soundscape Music for Psychedelic ExperiencesUnveiling the Soundscape Music for Psychedelic Experiences
Unveiling the Soundscape Music for Psychedelic Experiences
 
Jewish Resources in the Family Resource Centre
Jewish Resources in the Family Resource CentreJewish Resources in the Family Resource Centre
Jewish Resources in the Family Resource Centre
 

Mesics lecture 4 c operators and experssions

  • 1. Operators and Expressions www.eshikshak.co.in
  • 2. Introduction • An operator indicates an operation to be performed on data that yields a new value. • An operand is a data items on which operators perform operations. • C provides rich set of “Operators” – Arithmetic – Relational – Logical – Bitwise www.eshikshak.co.in
  • 3. Introduction www.eshikshak.co.in
  • 4. Properties of Operators • Precedence – Precedence means priority. – When an expressions contains many operators, the operations are carried out according to the priority of the operators. – The higher priority operations are solved first. – Example • 10 * 5 + 4 / 2 • 10 + 5 – 8 * 2 / 2 www.eshikshak.co.in
  • 5. Properties of Operators • Associativity – Associativity means the direction of execution. – When an expression has operators with same precedence, the associativity property decides which operation to be carried out first. a) Left to Right : The expression evaluation starts from the left to right direction Example : 12 * 4 / 8 % 2 48 / 8 % 2 6%2 0 b) Right to Left : The expression evaluation starts from right to left direction Example : X = 8 + 5 % 2 X=8+1 X=9 www.eshikshak.co.in
  • 6. Priority of Operators and their clubbing • Each and every operator in C having its priority and precedence fixed on the basis of these property expression is solved. • Operators from the same group may have different precedence and associativity. • If arithmetic expression contains more operators, the execution will be performed according to their priorities. www.eshikshak.co.in
  • 7. Priority of Operators and their clubbing • When two operators of the same priority are found in the expression, the precedence is given from the left most operators. x=5*4+8/2 (8 / ( 2 * ( 2 * 2 ) ) ) 2 1 1 2 3 3 www.eshikshak.co.in
  • 8. Comma and Conditional Operator • It is used to separate two void main() or more expressions. { • It has lowest precedence clrscr(); among all the operators • It is not essential to printf(“%d %d”, 2+3, 3-2); enclose the expressions } with comma operators within the parenthesis. OUTPUT : • Following statements are valid 5 1  a = 2, b = 4, c = a + b;  ( a=2, b = 4, c = a + b ); www.eshikshak.co.in
  • 9. Conditional Operator (?:) • This operator contains condition followed by two statements and values. • It is also called as ternary operator. • Syntax : Condition ? (expression1) : (expression2); • If the condition is true, than expression1 is executed, otherwise expression2 is executed www.eshikshak.co.in
  • 10. Conditional Operator (?:) • Example : void main() { clrscr(); printf(“Maximum : %d”, 5>3 ? 5 : 3) } OUTPUT : Maximum : 5 www.eshikshak.co.in
  • 11. Conditional Operator (?:) • Example : void main() { clrscr(); printf(“Maximum : %d”, 5>3 ? 5 : 3) } OUTPUT : Maximum : 5 www.eshikshak.co.in
  • 12. Conditional Operator (?:) • Example : void main() { clrscr(); 5 > 3 ? printf(“True”) : printf(“False”); printf(“%d is ”, 5>3 ? : 3) } OUTPUT : Maximum : 5 www.eshikshak.co.in
  • 13. Arithmetic Operator • Two types of arithmetic operators – Binary Operator – Unary Operator Operators Unary Binary Ternary www.eshikshak.co.in
  • 14. Arithmetic Operator • Binary Operator – An operator which requires two operator is know as binary operator – List of Binary Operators Arithmetic Operator Operator Explanation Examples + Addition 2+2=4 - Subtraction 5–3=2 * Multiplication 2 * 5 = 10 / Division 10 / 2 = 5 % Modular Division 11 % 3 = 2 (Remainder 2) www.eshikshak.co.in
  • 15. Arithmetic Operator • Unary Operator – The operator which requires only one operand is called unary operator – List of unary operator are Operator Description or Action - Minus ++ Increment -- Decrement & Address Operator Sizeof Gives the size of the operator www.eshikshak.co.in
  • 16. Unary Operator - Minus • Unary minus is used for indicating or changing the algebraic sign of a value • Example int x = -50; int y = -x; • There is no unary plus (+) in C. Even though a value assigned with plus sign is valid. www.eshikshak.co.in
  • 17. Increment (++) and Decrement (--) Operator • The ++ operator adds value one to its operand. • X = X + 1 can be written as X++; • There are two types ++ increment operator base on the position are used with the operand. www.eshikshak.co.in
  • 18. Pre-increment (i.e. ++x) int x =5, y; y = ++x; printf(“x = %dn y = %d”, ++x, y); OUTPUT : x = x + 1; x=7 y = ++x; y=6 y = x; www.eshikshak.co.in
  • 19. Post-increment (i.e. ++x) int x =5, y; y = x++; printf(“x = %dn y = %d”, x++, y); OUTPUT : y = x; x=7 y = x++; y=6 x = x + 1; www.eshikshak.co.in
  • 20. Pre-decrement (i.e. --x) int x =5, y; y = --x; printf(“x = %dn y = %d”, --x, y); OUTPUT : x = x - 1; x=3 y = --x; y=4 y = x; www.eshikshak.co.in
  • 21. Post-decrement (i.e. ++x) int x =5, y; y = x--; printf(“x = %dn y = %d”, x--, y); OUTPUT : y = x; x=7 y = x--; y=6 x = x - 1; www.eshikshak.co.in
  • 22. sizeof operator • The sizeof operator void main() gives the bytes { occupied by a variable. int x = 12; • i.e. the size in terms of float y = 2; bytes required in printf(“size of x : %d”, sizeof(x)); printf(“nsize of y :%d”, sizeof(y)); memory to store the value. } • The number of bytes OUTPUT : occupied varies from sizeof x : 2 variable to variable sizeof y : 4 depending upon its data type. www.eshikshak.co.in
  • 23. ‘&’ Operator • The ‘&’ returns the address of the variable in a memory. Address int x = 15 2040 printf(“%d”,x); Value 15 Variable X printf(“n%u”,&x); www.eshikshak.co.in
  • 24. Relational Operator • These operators are used to distinguish two values depending on their relations. • These operators provide the relationship between two expressions. • If the relation is true it returns a value 1 otherwise 0 for false. www.eshikshak.co.in
  • 25. Relational Operator Operator Description or Action Example Return Value > Greater than 5>4 1 < Less than 10 < 9 0 <= Less than or equal to 10 <= 10 1 >= Greater than or equal to 11 >= 5 1 == Equal to 2 == 3 0 != Not Equal to 3 != 3 0 www.eshikshak.co.in
  • 26. Assignment Operator • Assigning a value to a variable is very sample. int x = 5 Assignment Operator = *= /= %= += -= <<= >>= >>>= &= ^= != int x = 10; printf(“x = %dn”,x += 5); // x = x + 5; O/P x = 15 www.eshikshak.co.in
  • 27. Logical Operators • The logical operator between the two expressions is tested with logical operators. • Using these operators, two expressions can be joined. • After checking the conditions, it provides logical true(1) or false(0) status. • The operands could be constants, variables and expressions. www.eshikshak.co.in
  • 28. Logical Operators Operator Description or Action Example Return Value && Logical AND 5 > 3 && 5 < 10 1 || Logical OR 8 > 5 || 8 < 2 1 ! Logical NOT 8 != 8 0 i. The logical AND (&&) operator provides true result when both expressions are true otherwise 0. ii. The logical OR (||) operator true result when one of the expressions is true otherwise 0. iii. The logical NOT (!) provides 0 if the condition is true otherwise 1. www.eshikshak.co.in
  • 29. Bitwise Operator • C supports a set of bitwise operators for bit manipulation Operators Meaning >> Right Shift << Left Shift ^ Bitwise XOR (exclusive OR) ~ One’s Complement & Bitwise AND | Bitwise | www.eshikshak.co.in
  • 30. void main() two bits means the inputted number is to be divided by 2 s where Shifting of { s is the number of shifts i.e. in short y = n/2s int x, y; Where n = number and s = the number of position to be shift. clrscr(); For example as Thethe program keyword (x) ; print(“Read per Integer from scanf(“%d”, &x); // input value for x = 8 Y = 8 / 22 = 2 2 x>>2; y=x; printf(“The Right shifted data is = %d”, y); www.eshikshak.co.in }
  • 31. void main() three bits left means the number is multiplied by 8; in short Shifting of { y = n * 2s where n = number int x, y; s = the number of position to be shifted clrscr(); Asprint(“Read The Integer from keyword (x) ; per the program scanf(“%d”, &x); // input value for x = 2 Y=2*2 3 x<<=3; y=x; printf(“The Right shifted data is = %d”, y); www.eshikshak.co.in }
  • 32. void main() { int a, b, c; clrscr(); printf(“Read the integers from keyboard ( a & b ) :”); scanf(“%d %d”, &a, &b); c = a & b; printf(“The answer after ANDing is (C) = %d”, c); } OUTPUT : Read the Integers from keyboard (a & b) : 8 4 The Answer after ANDing is (C) = 0 www.eshikshak.co.in
  • 33. Table of exclusive AND X Y Outputs 0 0 0 0 1 0 1 0 0 1 1 1 www.eshikshak.co.in
  • 34. Binary equivalent of 8 Binary equivalent of 4 After execution C=0 Binary equivalent of 0 www.eshikshak.co.in
  • 35. void main() { int a, b, c; clrscr(); printf(“Read the integers from keyboard ( a & b ) :”); scanf(“%d %d”, &a, &b); c = a | b; printf(“The answer after ORing is (C) = %d”, c); } OUTPUT : Read the Integers from keyboard (a & b) : 8 4 The Answer after ORing is (C) = 12 www.eshikshak.co.in
  • 36. Table of exclusive OR X Y Outputs 0 0 0 0 1 1 1 0 1 1 1 0 www.eshikshak.co.in
  • 37. Binary equivalent of 8 Binary equivalent of 4 After execution C = 12 Binary equivalent of 0 www.eshikshak.co.in