Nguythang

tinhtong

Nov 9th, 2015
127
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.33 KB | None | 0 0
  1. #include<stdio.h>
  2. #include<stdlib.h>
  3. #include<conio.h>
  4. #include<math.h>
  5. #define ou printf(
  6. #define in scanf(
  7. int sum(int n);
  8. main()
  9. {
  10.     int n;
  11.     ou"Nhap vao so n = ");
  12.     in"%d",&n);
  13.     ou"tong cac chu so trong %d la %d",n,sum(n));
  14.    
  15. }
  16. int sum(int n)
  17. {
  18.     int s=0;
  19.     while (n!=0)
  20.     {
  21.         s+=n%100;
  22.         n/=100;
  23.     }
  24.     return s;
  25. }
Advertisement
Add Comment
Please, Sign In to add comment