Advertisement
nguyenhappy92

Hãy tính tổng các chữ số của số nguyên dương n

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