4 comments:

  1. $num1=$_POST["num"];
    $temp=$num1;
    $sum=0;
    while($temp>=1)
    {
    $sum+=$temp%10;
    $temp/=10;
    }
    echo "Sum of digits of $num1= $sum
    "

    ReplyDelete
  2. php
    $number=$_POST['num'];
    $sum=0;
    while($number!=0)
    {$digit=$number%10;
    $sum=$sum+$digit;
    $number=$number/10;
    }
    echo"the sum of digit is:$sum";
    ?>

    ReplyDelete
  3. $num=$_POST["n"];
    $temp=$num;
    $sum=0;
    while($temp>=1)
    {
    $sum+=$temp%10;
    $temp/=10;
    }
    echo "Sum of digits of $num=".$sum;

    ReplyDelete
  4. ?php
    $nos=$_POST["num"];
    $sum=0;
    while($nos>0)
    {
    $sum=$sum+$nos%10;
    $nos=$nos/10;
    }
    echo "Sum of digits : "."$sum";
    ?>

    ReplyDelete