বৃহস্পতিবার, ১৬ সেপ্টেম্বর, ২০১০

10. ARITHMETIC OPERATORS

Today I am going to write about Arithmetic operators. There are five arithmetic operators in C. They are
 
 

The operands acted upon by arithmetic operators must represent numeric values. Thus, the operands can be integer quantities, floating-point quantities or characters quantities. Remember one thing that character constants represent integer values, as determined by the computer's character set. The remainder operator (%) requires that both operands be integers and the second operand be nonzero.
     Division of one integer quantity by another is referred to as integer division. This operation always results in a truncated quotient. On the other hand, if a division operation is carried out with two floating-point quotient.

   Example:  Suppose that m and n are integer variables whose values are 15 and 4, respectively. Several arithmetic expressions involving these variables are shown below, together with their resulting values.



Notice the truncated quotient resulting from the division operation, since both operands represent integer quantities. Also, notice the remainder resulting from the use of the modulus operator in the last expression.

কোন মন্তব্য নেই:

একটি মন্তব্য পোস্ট করুন