Sunday, June 26, 2022

Logical operators

 Logical operators


Problem Statement
Given two integers a and b, your task is to check following conditions:-
1. If a <= 10 and b >= 10 (Logical AND).
2. Atleast one from a or b will be even (Logical OR).
3. if a is not equal to b (Logical NOT).


import java.io.*; // for handling input/output
import java.util.*; // contains Collections framework


class Main {

    public static void main (String[] args) {
        Scanner  sc=new Scanner(System.in);
             int a =sc.nextInt();
             int b =sc.nextInt();
            System.out.print((a<=10 && b>=10)+" ");
            System.out.print((a%2==0 || b%2==0)+" ");
            System.out.print((a!=b)+" ");
     }
    }

No comments:

Post a Comment

ads vert

Basic HTML Tables - Layout, HTML Tables, Attributes, Aside, Footer, Tr tag, Td tag, Th tag, Tbody

  Basic HTML Tables - Layout, HTML Tables, Attributes, Aside, Footer, Tr tag, Td tag, Th tag, Tbody < table >      < thead >    ...