Special Operators in C Language


Special Operators in C Language:

    • Below are some of special operators that C language offers.
 S.no
Operators
Description
1
&
This is used to get the address of the variable.
Example : &a will give address of a.
2
*
This is used as pointer to a variable.
Example : * a  where, * is pointer to the variable a.
3
Sizeof ()
This gives the size of the variable.
Example : size of (char) will give us 1.


Example program for & and * operators in C language:
    • In this program, “&” symbol is used to get the address of the variable and “*” symbol is used to get the value of the variable that the pointer is pointing to. Please refer C – pointer topic to know more about pointers.

Output:

50

Example program for sizeof() operator in C language:

    • sizeof() operator is used to find the memory space allocated for each C data types.

Output:

Storage size for int data type:4
Storage size for char data type:1
Storage size for float data type:4
Storage size for double data type:8

 Summary of C language operators types:

S.no
Types of Operators
             Description              
1
Arithmetic_operatorsThese are used to perform mathematical calculations like addition, subtraction, multiplication, division and modulus
2
Assignment operatorsThese are used to assign the values for the variables in C programs.
3
Relational operatorsThese operators are used to compare the value of two variables.
4
Logical operatorsThese operators are used to perform logical operations on the given two variables.
5
Bit wise operatorsThese operators are used to perform bit operations on given two variables.
6
Conditional(ternary) operatorsConditional operators return one value if condition is true and returns another value is condition is false.
7
Increment/decrement operatorsThese operators are used to either increase or decrease the value of the variable by one.
8
Special operators&, *, sizeof( ) and ternary operators
www.cinterviews.com appreciates your contribution please mail us the questions you have to cinterviews.blogspot.com@gmail.com so that it will be useful to our job search community

No comments:

 
Top Blogs