Skip to content

Commit

Permalink
Decimal to other base conversion
Browse files Browse the repository at this point in the history
  • Loading branch information
suhanigupta23 authored Feb 4, 2024
1 parent 5353cbd commit f7a9439
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions decimal_to_otherbaseconversion.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
//input taken as a number n in decimal base and
//input taken as a base b for the decimal base number n to convert into base b number
import java.util.*;
public class Program
{
public static void main(String[] args) {
Scanner scn=new Scanner(System.in);
int n= scn.nextInt();
int b= scn.nextInt();
int[] rem=new int[100];
int i=0;
while(n!=0)
{
rem[i]=n%b;
i=i+1;
n=n/b;
}
for(i=i-1;i>=0;i--)
{
System.out.print(rem[i]);
}

}
}

0 comments on commit f7a9439

Please sign in to comment.