Search This Blog

UI/UX Design | Web Development | Mobile Application Development

Whether you need UI/ UX design, web development services, or mobile app development services, Qaabil Digitals will be more than happy to help you. We work with top software developers, designers, and project managers. We tailor our services to suit your exact needs. We closely look at your company, listen to your story, and bring about the best ideas and solutions that can help you drive solid results. We don’t just produce work that works. We produce work that matters. Get a quote now Or Talk to us

Monday 13 June 2011

Using modulus or '%' operator in java program


class apmodulus
{
public static void main (String arg[])
{
int a=15,b;
b=a%5;
if (b==0)
System.out.println ("\n\t Divisible by 5 ");
else
System.out.println ("\n\t Not divisible by 5 ");
}
}

Note:
          Modulus operator returns remainder. In the above program variable 'a' will be divided by 5. If 5 divides 'a' properly (with out returning any decimal answer) then the message "Divisible by 5" will be showed otherwise statement associated with 'else' will be executed.

No comments:

Post a Comment

Share