_cronos2

e1.c

Oct 30th, 2014
221
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.49 KB | None | 0 0
  1. #include <sys/types.h>
  2. #include <unistd.h>
  3. #include <stdio.h>
  4. #include <stdlib.h>
  5.  
  6.  
  7. int main(int argc, char **argv){
  8.  
  9.     if(argc != 2){
  10.  
  11.         printf("No se ha llamado al programa de forma correcta: <path> <int>");
  12.         exit(-1);
  13.  
  14.     }
  15.  
  16.     int n = strtol(argv[1], 0, 10);
  17.  
  18.     pid_t child = fork();
  19.  
  20.     if(child == 0){
  21.  
  22.         printf(n % 2 ? "%d es impar\n" : "%d es par\n", n);
  23.  
  24.     } else {
  25.  
  26.         printf(n % 4 ? "%d no es múltiplo de 4\n" : "4|%d\n", n);     }
  27.  
  28. }
Advertisement
Add Comment
Please, Sign In to add comment