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

একজন অভিজ্ঞ প্রোগ্রামারের পরামর্শ

Write a program which can print the following sequences: Sample Output: 1, 10, 100, 1000, ……, N 1, 3, 6, 10, 15, ……, N

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