Question
Asked Nov 24, 2019
2 views

Explain various operators in c?

check_circle

Expert Answer

Step 1

Operators in C can be categorized into the following:

  • Arithmetic operators
  • Bitwise operators
  • Relational and logical operators
  • Assignment operators
  • Others

 

Arithmetic operators: They are used for arithmetic or mathematical operations:

 

Binary operators: They perform operations between two operands.

  • +: It is used to perform addition. For example, a + b
  • - : It is used to perform subtraction. For example, a - b
  • *: It is used to perform multiplication. For example, a * b
  • /: It is used to perform division. For example, a / b
  • %: It is used to get the remainder. For example, a % b

 

Unary Operators: They perform operations with a single operand.

  • Post-increment (++): It first executes the statement and then increments the value of an integer. For example, a++
  • Pre-increment (++): It is used to instantly increment the value of an integer. For example, ++a
  • Post-decrement (--): It first executes the statement and then decrements the value of an integer. For example, a--
  • Pre-decrement (--): It is used to instantly decrement the value of an integer. For example, --a
Step 2

Bitwise Operators:

  • The & (bitwise AND performs AND on every bit of two numbers. For example, a & b
  • The | (bitwise OR) performs OR on every bit of two numbers. For example, a | b
  • The ^ (bitwise XOR) performs XOR on every bit of two numbers. For example, a ^ b
  • The << (left shift) performs left shift on the bits of the first operand, the second operand decides the number of bits to shift. For example, a << b
  • The >> (right shift) performs right shift the bits of the first operand, the second operand decides the number of bits to shift. For example, a >> b
  • The ~ (bitwise NOT) inverts all bits of a number. For example, ~a

 

Relational Operators:

  • Equal to operator (‘==’): returns true when the two operands are equal, otherwise it returns false. For example, 2==2 will return true.
  • Not equal to operator (‘!=’): returns true when the two operands are not equal, otherwise it returns false. For example, 2!=3 will return true.
  • Greater than operator (‘>’): returns true when the first operand is greater than the second operand, otherwise it returns false. For example, 2>1 will return true.
  • Less than operator (‘<‘): returns true when the first operand is less than the second operand, otherwise it returns false. For e...

Want to see the full answer?

See Solution

Check out a sample Q&A here.

Want to see this answer and more?

Solutions are written by subject experts who are available 24/7. Questions are typically answered within 1 hour.*

See Solution
*Response times may vary by subject and question.
Tagged in

Engineering

Computer Science

Related Computer Science Q&A

Find answers to questions asked by student like you
Show more Q&A
add
question_answer

Q: 1:02 PM COmputer ScieNTE QUESTIONS ama answers/ What is... '@ Question: What is the output of the fo...

A: Explanation:The “==” sign in the “if” condition compare the two string reference types “abc” and “xy...

question_answer

Q: • What are the advantages of RSA compared to symmetric encryption algorithms?

A: DescriptionRSA AlgorithmRSA is an acronym for Rivest–Shamir–Adleman. This algorithm is based on asym...

question_answer

Q: Create a new file (in Dev C++) and save it as lab11_XYZ.cpp (replace XYZ with your initials). Create...

A: This C++ program contains header file swap_XYZ.h and cpp file lab11_XYZ.cppswap functions for int, c...

question_answer

Q: How do I code this on python heres the problem  Use the Design Recipe to define a function count_val...

A: Programming instructions: Define the function count_value which takes the list and a value as an arg...

question_answer

Q: WHY THE BLOCKCHAIN  TECHNOLOGY IS SAID TO HAVE POTENTIAL FOR BUSINESS AND ORGANIZATIONS?

A: After the creation of the internet, cryptocurrencies and their underlying blockchain technology are ...

question_answer

Q: Question in Image. I was wondering why they are not equal even thought their contents are the same

A: Code:

question_answer

Q: Odd man out: . Topological sort Algorithm DFS Algorithm Binary search Algorithm BFS Algorithm Prim's...

A: Answer:Binary Search AlgorithmExplanation:Topological sort Algorithm, DFS algorithm, BFS algorithm a...

question_answer

Q: JAVA threads confused help 1. A)Consider the Java program. What is the expected logical output? What...

A: Multithreading in java: It is an essential feature of java that performs two or more programs to run...

question_answer

Q: Find the employment age of each employee?

A: Select empno, ename datediff(YY,hiredate ,getdate()) as emp from emp; The above query prints the emp...