Sunday, March 25, 2018

Arithmetic operator of Java Programme

/* Example of Arithmetic Operator */
package Arithmetic;
public class Arithmetic
{
    public static void main(String[] args)
    {
        int a = 10, b =15, c = 20;
        float d;
        int result;
        d = (float)b/(float)a;
        prln("a = "+a);
        prln("b = "+b);
        prln("c = "+c);
        prln("Division : b/a = "+d);
        result = b % a;
        prln("\n Modulo: b%a = "+result);
        result = a * b + c;
        prln("\n Exprission : a*b+c = "+result);
        result = a + b * c;
        prln("\n Expression : a + b * c = "+result);
    }
    static void prln(Object anyObject)
    {
        System.out.println(anyObject);
    }
    static void pr(Object anyObject)
    {
        System.out.print(anyObject);
    }
   
}












Share:

0 comments:

Post a Comment

Blogger templates