Welcome, guest! Login / Register - Why register?
Psst.. new poll here.
Psst.. new forums here.
Microsoft is blocking us again (TY IP Reputation!) so just use oauth login instead. :)

Paste

Pasted as Java by D.Anusha ( 16 years ago )
import java.util.Scanner;
class wordcount
{
public static void main(String args[])
{
int count=0;
Scanner S=new Scanner(System.in);
System.out.println("enter string");
String a=S.nextLine();
int i=a.length();
for(int j=0;j<i;j++)
{
 char c=a.charAt(j);
 if(c==32)
 count++;
}
System.out.println("total no.of words are: " +(count+1));
System.out.println("length of string is: " +i); 

}
}

 

Revise this Paste

Your Name: Code Language: