This is a program to find number of digits.
Here is my code:
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
int main() {
    int i = 0, n;
    printf("Enter number: ");
    scanf("%d", &n);
    while ((n / pow(10, i)) != 0) {
        i++;
    }
    printf("%d", i);
}
This program gives 309 as the output (value of i) on any input. However, if I store the value of pow(10, i) in another variable and put it in while loop, I get the correct output. Please help!
 
     
     
    