Computer Science, asked by yashica4027, 7 months ago

Write a program to count number of ‘p’ in the string “pineapple

Answers

Answered by shreya4183
4

Answer:

public class count

{

public static void main(String args[])

{

String word = "pineapple" ;

int n=0 ;

int len = word. length() ;

for(int i=0; i<len ; i++)

{

chat ch = word. charAt(i) ;

if( ch=='p')

n++ ;

}

System. out. println("total no. of p:" +n) ;

}

}

Explanation:

please mark it brainliest

Similar questions