Discussion in 'C' started by vinayak saxena, Oct 10, 2010.
what is uses of operator % and what is work please tell me
% operator is used for modulus.. i.e. it takes out a remainder...e.g 2%3 gives you 2 and 4%2 gives you 0.
Use of % operator is mainly to see if the number is divisible by the second number or not.
2%3 gives you 2 and 4%2 gives you 0. why work that i dont know please tell me the working of modulus % operator
Just do 2 mod 3 using pen and paper and you will see that you get 2 as a remainder.
The '%' sign in c++ called the remainder.Which means that the remainder of some thing as when we devide 5 by 2 then 2 goes only 2 times as 2*2=4 which is less then 5 so the remaining thing is 1.this one is called remainder of 5 by two.it can be written as
I hope this enough for you to understand the working of '%' in c++.If it not works then tell me again.
Was there any subject in your school known as "Mathematics"? In mathematics there is a concept known as "remainder"...read that first and then ask question....
Separate names with a comma.