Advertisement
nguyenhappy92

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

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