Q:

Java program to multiply any positive number to 7

0

Java program to multiply any positive number to 7 

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

class GFG {    
    static int multiplyBySeven(int n)
    {
        /* Note the inner bracket here.
        This is needed because precedence
        of '-' operator is higher
        than '<<' */
        return ((n << 3) - n);
    }  
    // Driver code
    public static void main (String arg[])
    {
        int n = 4;       
        System.out.println(multiplyBySeven(n));
    }
}
// This code is contributed by Anant Agarwal.

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now