Operators in C Programming
Tags: cprogramming, programming, tutorial, beginners
Published: 2021-02-15 11:07:40

<p>In this tutorial, we will learn <a href="https://usemynotes.com/what-are-operators-in-c/">Operators in c programming</a>, and the types of unary and binary operators, and the difference between the unary operator and binary operator. So let us start.</p>
<h2>What are operators in c?</h2>
<p>An operator is a symbol or sign that operates on a value or a variable. In any of the programming languages, there are different-different types of mathematical & logical calculations. To perform the mathematical and logical operations some special symbols are used. For performing Different-different types of calculations the computer needs some symbols which are called an operator. For defining the data identifiers are used.</p>
<h2>What are the types of operators in c?</h2>
<p>There are two types of operators. The unary operator and the binary operator.</p>
<h2>Unary operator</h2>
<p>The operators which need only one operand for performing the operation are known as Unary operator. In the C language, the unary operators that are supported are of different - different types. For Example: -</p><table>
  <tbody>
    <tr>
      <th>Symbols</th>
      <th>Name</th> 
      <th>Symbols</th>
      <th>Name</th>      
    </tr>
    <tr>
      <td>&</td>
      <td>Address operator</td>  
      <td>*</td>
      <td>Indirection operator </td>     
    </tr>
    <tr>
      <td>+</td>
      <td>Unary +</td>  
      <td>-</td>
      <td>Unary -</td>     
    </tr>  
    <tr>
      <td>~</td>
      <td>bitwise operator</td>  
      <td>++</td>
      <td>Unary increment operator</td>     
    </tr>  
    <tr>
      <td>:</td>
      <td>Logical operator</td> 
      <td>--</td>
      <td>Unary decrement  operator</td>            
    </tr>   
  </tbody>
</table>
<h2>Binary operator</h2>
<p>Those operators who need two operands for performing the operations are known as binary operators. For example:</p>
<h3>Arithmetic operator</h3><p>An arithmetic operation will perform mathematical operations like addition, subtraction, multiplication, division, etc.</p>
<h3>Relational operator</h3>
<p>This operator checks the relationship between the two operands. If the relation is true then it returns the value 1 and if the relation is false then it returns the value 0.</p>
<h3>logical operator</h3><p>In the logical operator, the value 1 or 0 is returned depending upon whether the expression result is true or false.</p>
<h3>The ternary and conditional operator</h3>
<p>The ternary operator uses three operands instead of one or two. The condition operator checks the condition and assigns the value according to the condition.</p>
<h3>Increment and decrement operator</h3>
<p>These operators are used for incrementing or decrementing the value in a variable by 1.</p>
<h3>bitwise operator</h3>
<p>During the mathematical operations like addition, subtraction, etc. are converted into a bit-level for making the processing faster.</p>
<h3>Assignment operator</h3><p>This operator is used to assign a value to the variable. The most common assignment operator is =</p><h3>comma operators</h3><p>It is used to link related expressions together.</p><h3>Sizeof operator</h3><p>By using this operator we can get the size of the data</p><h2>What’s the difference between unary operators and binary operators?</h2>
<table>
    <tr>
      <th>Unary operator</th>
      <th>Binary operator</th>      
    </tr>
    <tr>
      <td>Performs the action with a single operand</td>
      <td>Performs the action with two operands</td>      
    </tr>
    <tr>
      <td>These contain the arithmetic operators</td>
      <td>These contain arithmetic, logical, conditional, relational operators</td>      
    </tr>
</table>