What is Algorithm?

If you want to know by bookish knowledge, then it defined that "Algorithm is a  process or set of rules to be followed in calculations or other problem-solving operations, especially by a computer or any logical devices. " But personally I think the algorithm is a structure of a code when programmers don't what to show his/her code. Now I share 10 basic, easy algorithm that everyone should know.




1. Determine the sum of the digits of a particular integer number :
It means that if anybody give you a number such as 12345 or 987456 then you determine how many digits in the number. Remember, if you do assume that number is a string, then it is easy to determine but if you assume that an integer number then that was not so easy.Don't scare, i am just kidding.It's easy. Because i show why
Every-time if divided your number with 10 and put it into a integer datatype number then it will kick last digit of you number like


int i = 132 ;
i = i / 10;
print i           //Here i value is 13
i = i / 10   
print i           //Here i value is 1

Every-time it reduce last number of the integer. It's happening because if you put a fraction number (1.2 or 9.6) into a integer then the integer just accept only figure number (1 or 9). So when we divided 132 with 10 then the result is 13.2, but i (integer) only accept 13. (13/10=1.3 ) then it accept only 1. After that 1/10=0.1 then i accept only 0.

Here is out solution. We have 3 thing to do,
  1. Check given number is equal 0 or not, if 0 then stop program
  2. Given number divided by 10.
  3. Count how many number is kicked.
I think there is a problem if you use dynamic programming language such as php , python. Because they change their datatype when they need to change. So when you give i = i / 10, then compiler make i a float variable and put whole number into it.

The code is here.