Operators in c part 2

Intelligent Operators

  • Three logical operators, namely OR, AND, and NOT. Although they are frequently used to compare conditions to determine whether they are satisfied or not, they can be used to compare Boolean values as well.When both operators are true or one, it returns true.When either operator evaluates to true or to one, it returns true.NOT: It is employed to change the operand’s logical state.
#include <stdio.h>
 
int main()
{
    int a = 1;
    int b = 0;
    printf("a or b = %d\n", a || b);
}

Output: a or b = 1

The Bitwise Operators

  • When executing operations at the bit level, a bitwise operator is utilised. They translate our input values into binary format and then process them using the appropriate operator to produce the desired outcomes.
#include <stdio.h>
 
int main()
{
    int a = 2; //10
    int b = 3; //11
    printf("a xor b = %d\n", a ^ b);
}

OUTPUT: a xor b = 1

Operators of assignments

  • Values are assigned using assignment operators. They will be incorporated into nearly every programme we create.
  • int a = 0;
  • int b = 1;
  • Equal to (=) is the assignment operator here. It is assigning 0 to a and 1 to b in the above example.
Shubhajna Rai
Shubhajna Rai

A Civil Engineering Graduate interested to share valuable information with the aspirants.

Leave a Reply

Your email address will not be published. Required fields are marked *

Get the latest updates on your inbox

Be the first to receive the latest updates from Codesdoc by signing up to our email subscription.

    StudentProjects.in