Advertisement
nguyenhappy92

Tổng chữ số nguyên dương n

Oct 14th, 2015
164
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.22 KB | None | 0 0
  1. // tinh tong cac chu so
  2. // Khai bao thu vien ct
  3. /*nclude<stdio.h>
  4. #include<conio.h>
  5. void main()
  6. {
  7. int n;
  8. scanf("%d",&n);
  9. long s=0;
  10. int a;
  11. while(n!=0)
  12. {
  13. a=n%10;
  14. s=s+a;
  15. n=n/10;
  16. }
  17. printf("%ld",s);
  18. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement