Search This Blog

If you have any problem or question please write in the comments. We will try to solve and send you the solution. Not just that we will also post your problems solution on our blog.

Wednesday, 22 June 2011

Java program using OR opeator


import java.util.*;
class usingor
{
public static void main (String arg[])
{
Scanner in = new Scanner (System.in);

int a,b;

System.out.print ("\n\t Enter value of a = ");
a=in.nextInt();

System.out.print ("\n\t Enter value of b = ");
b=in.nextInt();

if (a<=10 || a<b)
System.out.println ("\n\t a is less then b or 10 ");
if (b>=25 || b==a)
System.out.println ("\n\t b is greater than 25 or equal to a ");

}
}

Note:
          In the above program, after you entered values of variables, first statement will be executed 
  • If 'a' is less than or equal to 10 
          OR
  • 'a' is less than 'b'
          and second statement will be executed in this case
  • If 'b' is greater than or equal to 25
          OR
  • 'b' is equal to 'a'

    No comments:

    Post a Comment