Pergunta de entrevista da empresa Knoldus Software

Write a program to find length of integer without using library function?

Resposta da entrevista

Sigiloso

15 de nov. de 2016

As I was still thinking about previous question's reversal I wrote logic for reversing the number and he was like how can you find the length with this. I said sorry and wrote the following code: int lengthOfNum(){ scanf("%d", &num); while(num > 0){ count++; num=num/10; } printf("\nLength : %d", count); } He was not convinced and asked me to dry run the code for '10' and I don't know what I saw in my code and said that it will run infinitely. At this time I was totally out of mind.