Advertisement
Guest User

Lista Funções pt 2 - Ex 2

a guest
Aug 22nd, 2017
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.40 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. void conta (int a, int b, int *tot);
  4. int main ()
  5. {
  6. int a, b, tot=0;
  7. for (;;)
  8. {
  9. scanf("%d %d", &a, &b);
  10. if (a<=b&&a>0&&b>0)
  11. {
  12. conta(a, b, &tot);
  13. break;
  14. }
  15. }
  16. printf("%d", tot);
  17. }
  18. void conta (int a, int b, int *tot)
  19. {
  20. int i;
  21. for (i=a; i<=b; i++)
  22. {
  23. *tot+=i;
  24. }
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement