# C# Question on Modulus

I have a requirment for my new customer in our new e commerce website..I know I have to use modulus for solving this problem but need some help.

I have a requirement like

1 kit will have 100 pieces.
if Number of employees is 500 i have to allocate 5kits. if employees are 503 then I have to allocate 6 kits.

thanks in advance for helping me
###### Who is Participating?

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Commented:
Modulus is the remainder.

500 / 100 = 5

500 % 100 = 0

503 / 100 = 5

503 % 100 = 3

``````int num_of_emp = 503;

int num_of_kits = num_of_emp / 100;

if(num_of_emp % 100 != 0)
{
num_of_kits++;
}
``````
0
Author Commented:
thanks.  what if I have a configurable value instead of 100. say 5 or 10. what if the value 503 is less than the configurable value.

0
Commented:
Alternatively:

``````int piecesPerKit = 100;
int employees = 503;
int kits = (int)Math.Ceiling((double)employees / piecesPerKit);
``````
0

Experts Exchange Solution brought to you by

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Commented:
wdosanjos response will also work but assuming you want to use the modulus operator.

The value will not matter.

``````int num_of_emp = 73;
int piecesPerKit = 100;

int num_of_kits = num_of_emp / piecesPerKit ;  // will yeild 0

if(num_of_emp % piecesPerKit != 0) // modulus will yield 73
{
num_of_kits++;  // you will get 1 kit
}
``````
0
Author Commented:
Thanks to you both
0
###### It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
C#

From novice to tech pro — start learning today.