Skip to content

Commit

Permalink
printing digits in a number
Browse files Browse the repository at this point in the history
  • Loading branch information
suhanigupta23 authored Jan 27, 2024
1 parent 86e0fcd commit 50ebd87
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions printingdigitsinnumber.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import java.util.*;
public class Program
{
public static void main(String[] args)
{
Scanner scn=new Scanner(System.in);
int n=scn.nextInt();
int i;
int [] rem=new int[100];
int a=n;
int count=0;
for(;n>0;)
{
n=n/10;
count++;
}
n=a;
for (i=0;i<=(count-1);i++)
{
rem[i]=n%10;
n=n/10;

}
for(i=count-1;i>=0;i--)
{
System.out.println(rem[i]);
}
}
}

0 comments on commit 50ebd87

Please sign in to comment.