Ask a Teacher
What is difference between ‘/’ and ‘%’ operators in c++ ? Explain with a example. |
Mathematical operators are used to perform basic mathematical operations. Addition(+), subtraction(-), diversion(/), multiplication(*) and modulus(%) are the basic mathematical operators. Modulus operators cannot be used with floating-point number. '/ ' Divides numerator by the de-numerator . Example : Assume variable A holds 10 and variable B holds 20 then, B / A will give 2 ' % ' Modulus operator and remainder of after an integer division. Example : Assume variable A holds 10 and variable B holds 20 then, B % A will give 0 |