Computer Science, asked by abidkatalur8622, 21 days ago

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 sahilsinha29158sk
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