用while或do,while,逆序输入整数,用while或者for循环单独完成

从键盘输入一个整数,用while或do-while循环结构计算该整数的位数(用printf输出位数),用for循环将该整数各位逆序排列输出。比如输入985674,计算出该整数的位数(结果是6),然后按照逆序输出(476589)。
以上问题可以由while或者for循环单独完成

#include <stdio.h>
int main( )
{
    int n,i=0, a[100];
    scanf("%d",&n);
    do{
        a[i] = n%10;
        n /= 10;
        i++;
    } while (n>0);
    printf("%d\n",i);
    for (int j = 0; j < i; j++)
       printf("%d",a[j]);
    return 0;
}


如有帮助,望采纳!谢谢!

#include <stdio.h>
int main()
{
      long long n,m;
      int i,count=0;
      scanf("%lld",&n);
      m = n;
      while(m>0)
      {
          count++;
          m/=10;
      }
      printf("%d\n",count);
      for(i=0;i<count;i++)
      {
           printf("%d",n%10);
           n/=10;
      }
      return 0;
}