Operators in C
//operators in C programming language
//Operators: a symbol used to perform operations in given programming language
//Types of operators in C language
/*1. Arithmetic Operators
2. Relational Operators
3. Logical Operators
4. Bitwise Operators
5. Logical Operators
*/
//---------------------------------------
//Arithmetic Operators
/*(+): addition
(-): subtraction
(*): multiplication
(/): division
(%): modulus - gives remainder
*/
//---------------------------------------
//Relational Operators
/*(==): is equal to
(!=): is not equal to
(>): greater than
(<): less than
(>=): greater than or equal to
(<=): less than or equal to
*/
//---------------------------------------
//Logical Operators
/*(&&): logical AND operator. If both the operands are non-zero,
then the condition is true otherwise false
(||): logical OR operator. If any these two operands is non-zero
then condition becomes true
(!): logical NOT operator. it is used to reverse the logical state of its
operand. if conditon is true, then logical NOT operator will make it false
*/
#include <stdio.h>
int main()
{
int a,b;
a=0;
b=12;
printf("a&&b= %d\n", a&&b);
printf("a||b= %d\n", a||b);
printf("!b= %d", !b);
return 0;
}
//---------------------------------------
//Bitwise Operators: refer the above image
//---------------------------------------
// Other Bitwise Operators
/*(~): is the binary one's complement operator
(<<): is the binary left shift operator
(>>): is the binary right shift operator
*/
//Assignment Operators
/*(=): simple assignment operator
(+=): add and assignment operator [example: a+=1 means a=a+1]
(-=): subtract and assignment operator [example: a-=1 means a=a-1]
(*=): multiply and assignment operator [example: a*=1 means a=a*1]
(/=): divide and assignment operator [example: a/=1 means a=a/1]
*/
//Miscellaneous Operators: refer the above image
//---------------------------------------
//Operator Precedence in C: refer the above image
Comments
Post a Comment