import java.io.*;
class spaces
{
public static void main(String args[])throws IOException
{
int c=0;
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
System.out.println(" Enter a String ");
String s = br.readLine();
int l= s.length();
for(int i=0;i
char ch=s.charAt(i);
if(ch==' ')
c=c+1;
}
System.out.println("Number of spaces " + c);
}
}
No comments:
Post a Comment