Skip to main content

SMALLEST WORD

SMALLEST WORD




import java.util.Scanner;
class SmallestWord
{
    public static void main(String args[])
    {
        Scanner s= new Scanner(System.in);
        System.out.println(" Enter a Sentence ");
        String st=s.nextLine();
        st=" "+st;
        String st1; int n=0,m,max=0;
        int l=st.length();
        for(int i=0;i<l;i++)
        {
          m=st.indexOf(' ');
          st1=st.substring(m);
          n=st1.length();
        }
        if(n<max)
        System.out.println("The smallest word is "+n);
    }
}