IGNOU - MCSL025 - SECTION04 - [S01_E02]

♠ Posted by Unknown in , at 04:50

IGNOU - MCSL025 - SECTION04 - [S01_E02]

/*Author: Viral Vyas
 * Write a program in Java to find the result of following expression
 * (Assume a = 10, b = 5)
 * 1. (a<<2) + (b>>2)           2. (a)||(b>0)
 * 3. (a+b * 100) / 10          4. a & b
 */

package mcsl025;
import java.io.*;
import java.lang.*;

public class S01E02 {

    public static void main(String[] args) {

        int a = 10, b = 5;
        
        int c = (a<<2) + (b>>2);
        System.out.println("Output-1 : " + c);
        
        boolean d = (a != 0) || (b>0);
        System.out.println("Output-2 : " + d);
        
        double e = (a + b * 100) / 10;
        System.out.println("Output-3 : " + e);
        
        int f = a & b;
        System.out.println("Output-4 : " + f);
    }
}

Output:

Output-1 : 41
Output-2 : true
Output-3 : 51.0
Output-4 : 0

0 comments:

Post a Comment