Advertisement
hercioneto

programa C Divisao e Resto

Oct 16th, 2023
879
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.53 KB | None | 0 0
  1. // Online C compiler to run C program online
  2. /*Ler dois números inteiros, x e y, e imprimir o quociente e o resto da divisão inteira entre eles.
  3. */
  4. #include <stdio.h>
  5.  
  6. int main() {
  7.    int x, y, divisao, resto;
  8.    
  9.    printf("Digite numero x: ");
  10.    scanf("%i",&x);
  11.    printf("Digite numero y: ");
  12.    scanf("%i",&y);
  13.    
  14.    if (y !=0){
  15.    divisao = x / y;
  16.    resto = x % y;
  17.    }
  18.    else {
  19.    divisao = 0;
  20.    resto = 0;
  21.    }
  22.    printf("A divisão de %i por %i é %i ,restando %i",x,y,divisao,resto);
  23.    
  24.     return 0;
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement