Click the Twitter icon to follow our tweets and
know more about us.

WAP to enter any number and convert it to given base

class anybase
{
public static void display(int n,int b)
{String p=" "; int d,sum=0,e=1;;
String s[]={"0","1","2","3","4","5","6","7","8","9","A","B","C","D","E","F"};
while (n!=0)
{
d=n%b;
sum=d*(int)(Math.pow(b,e));
p=s[d]+p;
e++;
n/=b;
}
System.out.println(p);
}}

Comments (0)

Post a Comment