Advertisement
rayslhcf

1000+500+0+3

Aug 26th, 2014
237
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.46 KB | None | 0 0
  1. #include<stdio.h>
  2.  
  3. void display_components(int n);
  4. int main()
  5. {
  6.     int inp;
  7.     printf("Enter: ");
  8.     scanf("%d", &inp);
  9.     display_components(inp);
  10.  
  11.     return 0;
  12. }
  13.  
  14. void display_components(int n)
  15. {
  16.     int i, div, frc;
  17.     printf("= ");
  18.     for (i = 10000; i > 0; i/=10)
  19.     {
  20.         if((i-n)<=1)
  21.         {
  22.             div = n/i;
  23.             n = n%i;
  24.             printf("%d", div*i);
  25.             printf(i>9 ? " + ": NULL);
  26.         }
  27.     }
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement