Advertisement
paulogp

Divisão e resto (v. 1.0.2)

Jul 13th, 2011
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.81 KB | None | 0 0
  1. // Apple Xcode
  2.  
  3.  
  4. #include <stdio.h>
  5.  
  6. void minha_divisao(int the_quocient, int the_div, int *the_result_div, int *the_result_rest) {
  7.     *the_result_div = the_quocient / the_div;
  8.     *the_result_rest = the_quocient % the_div;
  9. }
  10.  
  11. int main (int argc, const char * argv[]) {
  12.     // insert code here...
  13.     int the_quocient = 0;
  14.     int the_div = 0;
  15.  
  16.     int the_result_div;
  17.     int the_result_rest;
  18.  
  19.     int the_flag = 0;
  20.  
  21.  
  22.     while (the_flag == 0) {
  23.         printf("Insira o quociente: ");
  24.         scanf("%i", &the_quocient);
  25.  
  26.         printf("Insira o dividendo: ");
  27.         scanf("%i", &the_div);
  28.  
  29.         if (the_div == 0) {
  30.             the_flag = 1;
  31.         } else {
  32.             minha_divisao(the_quocient, the_div, &the_result_div, &the_result_rest);
  33.             printf("div = %i\n", the_result_div);
  34.             printf("rest = %i\n", the_result_rest);
  35.         }
  36.     }
  37.  
  38.     return 0;
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement