Answer C10


#include <stdio.h>
#include <stdlib.h>
  
int main(int argc, char *argv[])
{
  int x, m, quot, rm;
  
  if ( argc != 3 )
  {
    printf("xModm x m\n");
    printf("display x/m and x%%m\n");
    return 0;
  }
  
  x = atoi( argv[1] );
  m = atoi( argv[2] );
  
  quot = x/m;
  rm  = x%m;
  
  printf("%d / %d = %d;\t", x, m, quot );  
  printf("%d %% %d = %d;\t", x, m, rm );
  printf("%d*%d + %d = %d;\n", m, quot, rm, m*quot+rm );
   
  return 0;
} 
 


Back to Puzzle Home