Online Compiler C

#include <stdio.h> int main() { long long int m; int q=0; scanf("%lld", &m); while (m>0) { m /= 10; q++; } int A[q] = {0}; while (m>0 ) { int i = 4 ; A[i] = m%10; i--; } for(int i = 0 ; i < q; i++) { printf("%d ",A[i]); } return 0; }
The code reads an integer, counts its digits by repeatedly dividing by 10, then tries to store each digit into an array. However, after counting digits, the variable `m` becomes 0, so the second loop never runs. Also, the array index `i` is reset to 4 each iteration, which is incorrect.

- The first loop destroys the original value of `m` by dividing it until it becomes 0. You need to preserve the original number or use a copy for digit extraction.
- In the second loop, the index `i` is set to 4 every time, so all digits would be stored at the same position. You should start from the last index and decrement properly, but first ensure the loop condition works with a non-zero value.