Biggest Among Two Numbers Without using Any Control Statements or Any More Variables


package com.nano.BigNum;
 import java.io.DataInputStream; 
import java.math.*; 
public class BigstNum
 { 
 /** * * Author : karthik.T * Date : 16-07-2012 * */ 
 public static void main(String[] args) { 
 try
 {
 int a,b,c;
 System.out.println("Biggest Among Two Numbers ");
 System.out.println("Condition : No cntrl , No Loop , No mre var Xcept a,b,c"); System.out.println("Enter a and b Values : "); 
 DataInputStream g=new DataInputStream(System.in); 
 a=Integer.parseInt(g.readLine()); 
 b=Integer.parseInt(g.readLine()); 
 c=a+b; 
 System.out.println("The Biggest Among a="+a+" and b="+b+" is : "+ (c+Math.abs(a-b))/2 ); } //try closed catch(Exception e) { } 
 } 
 // main method closed } // class closed

No comments:

Post a Comment

Pages