Friday, July 31, 2020

Write a program to input a number and find the Super Digit of this number.(7645, number’s largest digit+1=super digit, 7+1=8)

63)  Write a program to input a number and find the Super Digit of this number.(7645, number’s largest digit+1=super digit, 7+1=8)


import java.util.*;
public class Super_digit
{
   public static void main(String args[ ])
   {
              Scanner sc = new Scanner (System.in);
              System.out.println("Enter a number");
              int a = sc.nextInt();
              int c = 0;
              while(a>0)
              {
                  int d = a%10;
                  if(d>c)
                  {
                      c=d;
                  }
                  a=a/10;
              }
              System.out.println("Super digit = "+(c+1));
   }
}

Output :





 

No comments:

Post a Comment

if you have any doubts, Please let me know.
Your Truly
Shashank Porwal

 jhvghvgk ;nkjn ,nkjhj