Anik_Akash

102_Digit_Sum_CF

Apr 23rd, 2020
337
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <stdio.h>
  2. int main()
  3. {
  4.    int n, rev = 0, remainder, x, count=0;
  5.  
  6.     scanf("%d", &n);
  7.  
  8.     while (n != 0)
  9.     {
  10.         remainder = n % 10;
  11.         rev = rev * 10 + remainder;
  12.         n /= 10;
  13.  
  14.     }
  15.     while(rev != 0)
  16.     {
  17.         x = rev%10;
  18.         rev = rev/10;
  19.         if(x != 0)
  20.         {
  21.             count++;
  22.         }
  23.     }
  24.  
  25.     printf("%d\n", count);
  26.  
  27.     return 0;
  28. }
RAW Paste Data