Write a program which takes a string as input and finds the number of occurrence of “i”.

Problem number : 2


Write a program which takes a string as input and finds the number of occurrence of “i”.

Sample Input:

University

Sample Output:

2


Solution For this problem :

<?php
//echo "Hello World !";
echo "<br/>";
$name="university";
$count=0;
 
for($i=0;$i<strlen($name);$i++)
{
if($name[$i]=="i")
{
$count++;
}
}
echo $count;
echo "<br/>";
echo "<br/>";
?>


Sample Input:

University

Sample Output:

2

মন্তব্যসমূহ

Popular Posts

Simple 2D hut design in computer graphics using c++

HashMap in Java