Clouds
Home
Tutorial of C language
Computer Language
Introduction to C
Programming in C
Structure of C program
Variable in C
Datatypes in C
Token in C
Operator in C
Precedence of C Operator
Assignment Operator in C
Logical Operator in C
Bitwise Operator in C
Ternary Operator in C
C Input Output
Pointers in C
Storage Classes of C
Control Structure of C
C Decision Making Statement
C Looping Statement
C Jumping Statement
C Function
Function Call By Value
Function Call By Reference
C Input Output Function
C Structure
Array in C
Union in C

Operators in C

  • Operator are symbols that specifies the operation and extend the processing capabilities
  • The variable, constant can be joined by various operators to form an expression.
  • Simple answer can be given using expression 4 + 5 is equal to 9. Here 4 and 5 are called operands and + is called operator. C language supports following type of operators.
    The operators are classified into various categories
  • Arithmetic Operator
  • Relational Operator
  • Logical Operator
  • Assignment Operator
  • Ternary Operator
  • Bitwise Operator
  • Increment and Decrement Operator
  • Special Operator

    Arithmetic Operator

    The operators that are used to perform arithmetic operations such as addition, Subtraction,Multiplication etc are called arithmetic operator.
    Operator Meaning Purpose Example
    + Plus Addition 5+2=7
    - Minus Subtraction 5-2=3
    * Asterisk Multiplication 5*2=10
    / Slash Division 5/2=2
    % Modulus Remainder 5%2=1
    Example:
    				void  main()
    				{
    					int a=5,b=2,sum,sub,mul,div,rem;
    					sum=a+b;
    					sub=a-b;
    					mul=a*b;
    					div=a/b;
    					rem=a%b;
    					printf("%d",sum);
    					printf("%d",sub);
    					printf("%d",mul);
    					printf("%d",div);
    					printf("%d",rem);
    					getch();
    				}
    				

    Relational Operator

    The relational operators also called comparison operators are used to compare two operands and hence are called relational operators.
    Operator Meaning Example
    > Greater Than 5>2
    < Less Than 2<5
    >= Greater Than or Equal 5>=5
    <= Less Than or Equal 2<=2
    = = Equal 5==5
    != Not Equal 5!=2
    Example:-
    				#include<stdio.h>
    				#include<stdio.h>
    				void  main()
    				{
    				   	int a = 21;
    				   	int b = 10;
    				    if( a == b )
    				   	{
    				   		printf(" a is equal to b\n" );
    				   	}
    				   	else
    				   	{
    				      	printf(" a is not equal to b\n" );
    				   	}
    				   	if ( a < b )
    				   	{
    				      	printf(" a is less than b\n" );
    				   	}
    				   	else
    				   	{
    				      	printf("a is not less than b\n" );
    				   	}
    				   	if ( a > b )
    				   	{
    				      	printf("a is greater than b\n" );
    				   	}
    				   	else
    				   	{
    				   		printf(" a is not greater than b\n" );
    				   	}
    					getch();
    				}
    				


    Precedence of C Operator >>
    Assignment Operator in C >>
    Logical Operator in C >>
    Bitwise Operator in C >>
    Ternary Operator in C >>


    Home Clouds