In this article, We’ll write a program to sum of digits in php.
For example, we’ve a number i.e 12345, when we calculate the sum of digits, the output should be come 15.
$number = 12345; $num = $number; $sum = 0; $rem = 0; for ($i = 0; $i <= strlen($num); $i++) { $rem = $num % 10; // % return remainder $sum = $sum + $rem; $num = $num / 10; } echo "Sum of digits $number is $sum"; // Output Sum of digits 12345 is 15
That’s it!. Please share your thoughts or suggestions in the comments below.
These are actually great ideas in regarding blogging. You have touched some important points here.
Any way keep up writing.
Hi! This is my first visit to your blog! We are a group of
volunteers and starting a new initiative in a community in the same niche.
Your blog provided us useful information to work on.
You have done a wonderful job!
Keep up the good work!
It’s awesome to pay a visit this site and reading the views of all friends
on the topic of this post, while I am also keen of getting experience.
writing service
https://essaywritingusauk.com/
Amazing! Its actually amazing paragraph, I
have got much clear idea on the topic of from this post.
service essays
https://toppaperwritinghelp.com/
I couldn’t resist commenting. Perfectly written!
essay writers
https://buyessaysearch.com/
Piece of writing writing is also a fun, if you know
then you can write or else it is complicated to
write.
I read this piece of writing completely regarding the comparison of hottest and earlier technologies,
it’s amazing article.
You have made some good points there. I looked on the internet to find out more about the
issue and found most people will go along with your views on this site.
Why users still use to read news papers when in this technological globe everything is available on web?