# % operator

Discussion in 'C' started by vinayak saxena, Oct 10, 2010.

1. ### vinayak saxenaNew Member

Joined:
Oct 10, 2010
Messages:
2
0
Trophy Points:
0
what is uses of operator % and what is work please tell me

2. ### techgeek.inNew Member

Joined:
Dec 20, 2009
Messages:
572
19
Trophy Points:
0
Occupation:
EOC (exploitation of computers)..i m a Terminator.
Location:
Not an alien!! for sure
% 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.

3. ### go4expertModerator

Joined:
Aug 3, 2004
Messages:
306
9
Trophy Points:
0
Use of % operator is mainly to see if the number is divisible by the second number or not.

4. ### vinayak saxenaNew Member

Joined:
Oct 10, 2010
Messages:
2
0
Trophy Points:
0
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

5. ### go4expertModerator

Joined:
Aug 3, 2004
Messages:
306
9
Trophy Points:
0
Just do 2 mod 3 using pen and paper and you will see that you get 2 as a remainder.

6. ### aftabsharifNew Member

Joined:
Oct 15, 2010
Messages:
3
0
Trophy Points:
0
Location:
Bahawalpur
Hi,
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
5%2=1.
I hope this enough for you to understand the working of '%' in c++.If it not works then tell me again.

7. ### techgeek.inNew Member

Joined:
Dec 20, 2009
Messages:
572
19
Trophy Points:
0
Occupation:
EOC (exploitation of computers)..i m a Terminator.
Location:
Not an alien!! for sure
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....