C Operators

Special Operators


C supports some special operators of interest such as comma operator, size of operator, pointer operators (& and *) and member selection operators (. and ->).
The size of and the comma operators are discussed here. The remaining operators are discussed in forth coming chapters.

The Comma Operator


The comma operator can be used to link related expressions together.
A comma-linked list of expressions are evaluated left to right and value of right most expression is the value of the combined expression.
	For example the statement 
		value = (x = 10, y = 5, x + y);
        
First assigns 10 to x and 5 to y and finally assigns 15 to value. Since comma has the lowest precedence in operators the parenthesis is necessary

The size of Operator


The operator size of gives the size of the data type or variable in terms of bytes occupied in the memory. The operand may be a variable, a constant or a data type qualifier.
		Example 
			m = sizeof (sum);
			n = sizeof (long int); 

The size of operator is normally used to determine the lengths of arrays and structures when their sizes are not known to the programmer.
It is also used to allocate memory space dynamically to variables during the execution of the program.

Make Comments..!!


Oops!! No posts from user.

Download Android App