Sunday, 20 October 2013

Java program to find the greater of two numbers without using any relational operator ...

Here is the code .....



       
import java.io.*;
import java.util.*;

public class Greater {

 int great(int a, int b) {
  int c = a - b;
  int k = (c >> 31) & 0x1;
  System.out.println(k);
  //int g=a-k(a-b);
  return a - k * (a - b);
 }
 public static void main(String args[]) {
  int a = 6, b = 3;
  Greater d = new Greater();
  System.out.println("the greater no. is " + d.great(a, b));
 }
}

       
 

No comments:

Post a Comment