What are the restrictions of a modulus operator?

What are the restrictions of a modulus operator?

The modulus operator is denoted in c by symbol %.

we have two integer values x and y and then the operation x % y called as x modulus y gives the result as (x- (x / y) * y).

Say if x=18 and y =5 the x % y gives value as (18- (18 / 5) * 5) which gives (18-15) which results in 3 in other words the remainder of the division operation.

But there is a restriction in C language while using the modulus operator. There are two types of numerical data types namely integers, floats, double. But modulus operator can operator only on integers and cannot operate on floats or double. If anyone tries to use the modulus operator on floats then the compiler would display error message as �Illegal use of Floating Point�.

By:Vivek Kr. Agarwal
Date:2029-12-08 00:00:00

1)modulus operator works as a%b=reminder (sign as reminder is the sign of a). eg: a)3%2=1,
in case a only the answer is correct but not in b,c,and d .that's the limitation of modulus operator .
2) it can't works with float and double 

By:arun raheja
Date:0000-00-00 00:00:00

Post Your Answers

User Email:

User Name:

Related C Subjective Links

C Subjective interview questions and answers for experienced and fresher