Go to Top

Friday 16 December 2011

Libraries 3 : Mod function

Here's the replica of the widely used Mod Function (%). You may even use it in your program as :

// Rest part of the program is omitted
int m=39,n=7,result;
result=mod.cal(m,n);
System.out.print(result);

Java Program :

class mod
{
 static int cal(int number,int mod)
 {
     for(;;)
     {
         if(number>=mod)
         number=number-mod;
         else
         return number;
        }
    }
}

2 comments:

  1. You need not use this function, but this program will definitely make your Blue J project nicer to look at.

    ReplyDelete
  2. Thanks for this wonderful post ! Please keep it up ! You haven't been posting for days, so please start posting once again.

    ReplyDelete

ShareThis