Write a à program to count word's starting with alphabet' a' in a string? Ip: an apple in a basket. O/p: 3
Answers
Answered by
1
Answer:
in java
char ch = 'a';
int sum=0;
String sentence = "an apple in a basket";
for (i==0; i==sentence.length() ; i++) {
if(sentence.charAt(i) == ch){
sum+= 1;
}
}
System.out.println(sum);
Similar questions