Displays the results of applying the modulus operation. - C Operator

C examples for Operator:Modulus Operator

Description

Displays the results of applying the modulus operation.

Demo Code

#include <stdio.h>

int main(void){
  int first, second;
  printf("Enter an integer to serve as the second operand: ");
  scanf("%d", &second);

  printf("Now enter the first operand: ");
  scanf("%d", &first);

  while (first > 0)
  {/*from   w w w  .j a va  2s .  co m*/
    printf("%d %% %d is %d\n", first, second, first % second); //print results

    printf("Enter next number for first operand (<= 0 to quit): ");
    scanf("%d", &first); // get new input
  }

  return 0;
}

Result


Related Tutorials