PedroQuintans

Untitled

Sep 6th, 2017
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.59 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4. int main()
  5. {
  6. int num1, num2, i, soma=0, aux;
  7.  
  8. do{
  9. soma=0;
  10. scanf("%d %d", &num1, &num2);
  11.  
  12. if(num1<num2){
  13. for(i=num1;i<=num2;i++){
  14. printf("%d ", i);
  15. soma+=i;
  16. }
  17. printf("Sum=%d\n", soma);
  18. }
  19.  
  20.  
  21. if(num1>num2){
  22. aux=num2;
  23. num2=num1;
  24. num1=aux;
  25.  
  26. for(i=num1;i<=num2;i++){
  27. printf("%d ", i);
  28. soma+=i;
  29.  
  30. }
  31. printf("Sum=%d\n", soma);
  32. }
  33.  
  34. }
  35. while(num1>0 || num2>0);
  36.  
  37. return 0;
  38. }
Advertisement
Add Comment
Please, Sign In to add comment