php - Write a program to count the number of occurrence of digit in a number. Email ThisBlogThis!Share to TwitterShare to Facebook Reactions: Labs 5 Comments
$num1=$_POST["num"];
ReplyDeletefor ($i=0;$i<=9;$i++)
{$count=0;
$temp=$num1;
while($temp>=1)
{
if($i==$temp%10)
{
$count++;
}
$temp/=10;
}
echo "Occurence of $i= $count
";
php
ReplyDelete$n=$_POST['num'];
$digit=$_POST['num1'];
$count=0;
while($n>=1)
{$temp=$n%10;
if($digit==$temp)
$count++;
$n=$n/10;
}
echo "$count";
?>
This comment has been removed by the author.
ReplyDelete$n=$_POST['n'];
ReplyDelete$x=$_POST['n1'];
$count=0;
while($n>=1)
{$y=$n%10;
if($x==$y)
$count++;
$n=$n/10;
}
echo "$count";
?php
ReplyDelete$nos=$_POST["num"];
$d=$_POST["dig"];
$count=0;
while($nos>=1)
{
$a=$nos%10;
if($d==$a)
{$count++;
$nos=$nos/10;}
}
echo"digit repeated "."$count". " times .";
?>